Form bound to datatable does not update on data source changes

Hi there,

I tried to bind a form to a datatable and so for this works fine. The issue is that the bound item does not get updated if the data changes.

Please see the following example:

http://webix.com/snippet/b93e0e5b

Select row with “a2” from the table and press “Do something” on the form. After two seconds the value “b2” will change to “b2 changed” but it is changed on the datatable only.

Because this does not work I tried to find a event that is fired on the datatable as soon as the row changes to update the form manually but I had no luck. I had no luck trying to follow the source either.

What am I doing wrong?

Thanks for your help!

Hi,

The following should work for form-collection binding:

form.save();

or

collection.updateItem(data.getCursor(), newData);

However, there is the issue with updateItem in minified webix.js ( updateItem works with webix_debug.js). We will include the fix into the next minor update.

Hi again,

We have updated the packages - please download the new package with the fix.

Hi Maria,

thanks for your fast reply.

form.save() is updating the collection bound to the form which works fine. collection.updateItem is what doesn’t work (even with webix_debug-js). It updates the collection and the grid receives the update but the form bound to the grid does not. This is what my example demonstrates.

We are working with event messaging which means if I call form.save() the message gets passed to the server and the job is done (no reply). Later a message arrives from the server with the updated data and this is where I have to update the collection and anything directly (grid) or indirectly (form).

Hi,

Thanks for clarification. Please call refreshCursor() for a master collection (table) to update the form:

http://webix.com/snippet/e9ab01af

Thanks Maria,

I tried this too but this does not help in my case because the part that updates the datacollection has no idea about what is bound to it (I think that’ s one of the main points for using a binding).

To use refreshCursor() I need to know that the data has changed. I was unable to find an event that is fired on the datatable after a collection.updateItem() which means I don’t know when I have to call refreshCursor() because the data has changed.

Hi,

Possibly it will be better to bind the form and the datacollection and set the cursor on row selection:

http://webix.com/snippet/129b389b

Hi Maria,

yes, this is what I did as a workaround but I am not sure if I like this solution. The binding to the datatable looks much cleaner to me because this is where the form receives it’s data from. Just thought I was doing something wrong for the binding not working as I thought it should.

However, if there is no solution to get the datatable binding working, this solution is fine with me.

Thank you very much for your help.

Hi again,

It is possible to use onStoreUpdated event handler. It should be set after the form is bound to the datatable:

http://webix.com/snippet/eb58f093