I need add the element of a one datacollection, get ID from server side, add the element of a two datacollection with the last ID form one collection.
How can I do it?
I need add the element of a one datacollection, get ID from server side, add the element of a two datacollection with the last ID form one collection.
How can I do it?
get ID from server side
If data saving is enabled, the backend should return the server-side ID as the newid
parameter of server response.
In such case, the item will be updated automatically with the server-side ID.
add the element of a two datacollection with the last ID form one collection
For sharing the data between collections, please consider syncing the data - all updates of the parent collection will affect the linked data sources.
I meant a little another. In my case the data saving is enbled, the collections are linked. Befor getting newid from server time passes, but i need to use newid immediatly in second adding of collention.
For example:
var id_client = clientsСollection.add({
active: true,
name: "name",
});
thingСollection.add({
id_clien: id_client,
active: true,
name: "name",
});
In this case, “id_clien” of “thingСollection” will be write a temprorary ID, but i need a persistent server ID.
There is no good solution here.
It possible to track ID change by using onIdChange event ( https://docs.webix.com/api__datastore_onidchange_event.html ) but it will result in rather complicated code.
We can extend this a bit in next version so you will be able to use code like next
clientsСollection.add({
active: true,
name: "name",
});
webix.dp("clientsСollection").$wait.then(
(obj) => thingСollection.add({
id_clien: obj.id,
active: true,
name: "name",
});
)