jQWidgets Forums
jQuery UI Widgets › Forums › DataTable › Seamless refresh of table data (selection disappears)
This topic contains 11 replies, has 4 voices, and was last updated by Peter Stoev 10 years, 6 months ago.
-
Author
-
Hello!
I would like to create a table that refreshes its content from remote data source periodically. It is almost done by calling datasource.dataBind() function by a Javascript timer, though I have a problem with the row selection. After refreshing the row selection disappears and I cannot find a way to preserve it.
It is not trivial either to save the selected row index, because I can only get selected row index by rowSelect event, and it does not take table sorting into account when returning selected index.Is there a simple solution?
Thanks in advance,
AkosHi Akos,
The “updateBoundData” should be used for refreshing the DataTable’s data periodically.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter!
Thanks for the response.
I tried this:
$(“#table”).jqxDataTable(‘updateBoundData’)Sadly it also clears row selection, in addition the progress indicator is blinking continuously.
Regards,
AkosHi Akos,
Yes, the selection will be cleared due to the reason that the data is refreshed and the widget is re-rendered. If you want to keep the state, you will have to manually get the selected row index and call the selectRow method after the rebinding.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter!
Ok, no problem with this solution. But how can I get the index of the selected row?
I can only find “rowSelect” event, where I can get row index, but it is not working, because it does not take sorting into account. In contrast the “selectRow” method does selection according to the actually visible order. So I cannot save and restore selection this way.
Thanks,
AkosHi Peter!
You can also see the phenomenon in the example:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxdatatable/index.htm#demos/jqxdatatable/javascript-datatable-rows-selection.htmIf you use an unsorted table, then the Selected Row Indexes indicator and the Select row textfield have the same meaning. But if you sort the rows (for example by quantity), then these values will have different meaning.
I can’t find a way in the API reference to solve this.
Thanks,
AkosHi Akos,
It is not a phenomen 🙂 The rowSelect event gives you the Data Bound Index as information, the selectRow method enables you to select a row by its Display Index because it is more intuitive. The solution would be if you give additional parameters in the rowSelect event and we will probably implement that in a future version.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi Peter,
The selectRow method behavior is a problem for us to. We really need a method to select a row in the DataTable using the Data Bound Index as the parameter.
Thanks a lot.
FredericHi Frederic,
I am sorry, but such method is not available and is not planned as well.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com/Guys, how you solved this issue? I cannot find the way how to get selected row index before refresh. rowSelect event not works for me also.
And even more – to solve issue with sorting(and for other needs) I’m storing selected row data. The only one way I can see to solve the issue is to use getView and loop to find selected index.
Hi Mardok,
rowSelect returns the selected row’s index and also the bound index in the current DataTable version.
$('#dataTable').on('rowSelect', function (event) { // event args. var args = event.args; // row data. var row = args.row; // row index. var index = args.index; // row's data bound index. var boundIndex = args.boundIndex; // row key. var key = args.key; });
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.