selection is dropped from synced datacollections when data is updated

This is quite annoying bug/feature:

When two datatables are synced and user selects item in the slave datatable. If meanwhile data in the master is being updated selection in the slave is dropped. Here is the code example:

https://snippet.webix.com/atw3fv12

This happens even if we sync datatables with non-ui datacollection:

https://snippet.webix.com/e152pnet

Is there any workaround for this?

Thank you in advance!

Hello @Ingvord ,
It’s not a bug. setCursor method is supported only by collections. More information about it is here
In visible components, such method is useless, cause it’s the same as select
Ultimately, binding depends on the select of the visible components and the position of the cursor in the collections

Hello @Nastja ,

Thanks for the quick response.

Sorry, it seems provided code examples are misleading - setCursor has nothign to do with the issue. My scenario is the following: user clicks on a datatable that is synced with another one. The row is highlighted - OK. But then if the master data is updated, via parse, for instance. The selection in the datatable disappears.

I have updated the code snippet: https://snippet.webix.com/icccuobr

If you remove the last line, selection is there, as expected.

So the question is - is there a workaround to preserve selection in the slave component?

Select is applied to a data item with a specific ID. When the data is updated, all data in the datatable is completely updated - the select should be reset in this case.

For example, if you use bind you can select row via onBindApply event

onBindApply:function(){ 
  if (this.getFirstId())
    this.select(this.getFirstId());              
} 

And Webix datatable provides a possibility to store/restore the state of the grid
For example to save the current datatable state to the local storage you should call the getState method as in:

var state = grid.getState();
webix.storage.local.put("state", state);

So you can save in the browser local store some parameters and restore them after the reboot
More information is here