Hi,
in the training we see how to create a dataprovider in angular (spec file and js file).
We have seen that a dataprovider has a specific dataprovider type.
But my question is:
Is it possible to assign an array or json object as dataprovider now?
This UI looks to me like a regular Form in ListView mode, which is already supported in the NGClient as well.
If you want to build a component which offers such a UI, there are multiple options, depending on how you want to bind to data:
FoundSet: if you want to make something that binds to a FoundSet, best is to wait a bit, since the current API to work with FoundSets in components is not yet stable and also not documented. But if you’re eager to try it out, have a look at the servoydefaults/portal implementation, which is foundset based.
If you want to bind to a DataSet or plain JavaScript object, you can already build such a thing, providing the data through an api method, like setData(dataset) for example.
I try using api function and work as well.
But for the philosophie of the webcomponents i want to assign data in another way.
i tried to set an Array as dataProvider of the webcomponent.
I add a watcher in the link property of the component but when i add a new entry on dataprovider the listener is not executed.
yes that will not work, because servoy does not see the change
You really have to do dataprovider = xxxx
this is the same thing as doing dataprovider.setTime(xxx) for a date, you have to reassign it, you can’t alter some internal state and expect that servoy sees that
Ok i understand the reason why servoy don’t sees the changes of the dataprovider.
So, is more correct to call this variable foundset that dataprovider.
So, the unique way to do that is to create a variable in model section, encapsulate it in set/get methods for read and write the values, and call scope.svyApply(“modelVar”) for to comunicate the client changes (if there are) on server and sync the values.