EasyUI Forum

General Category => Bug Report => Topic started by: mzeddd on April 11, 2014, 02:00:21 AM



Title: DataGrid:getSelections vs reload
Post by: mzeddd on April 11, 2014, 02:00:21 AM
I see the following problem:

Lets have datagrid with toolbar for example
1) I select one line and press "button1" which shows number of selected lines.
It returns "1" - OK
2) Line is still selected and I press "button2" to update URL for DataGrid and reload it. In new set of data "selected" line is available
Datagrid updated, previousely selected line stays selected - OK
3) Line is still selected and I press "button3" to update URL for DataGrid and reload it. In new set of data but "selected" line is NOT available
I have new data, I don't see any selected lines - OK
4) I press "button1" and expect to see no selected lines
But once again it returns "1". And I could get ID for this record(s)

//V



Title: Re: DataGrid:getSelections vs reload
Post by: stworthy on April 12, 2014, 03:03:33 AM
If you set 'idField' property, the datagrid will store the selected rows. When reloading data, the datagrid will find the rows in current page via 'idField' and set them selected. If you update a selected row with different 'id' value without calling 'updateRow' method, the selected status may lose but the selected row still exists.
To solve this issue, try to call 'updateRow' method to update a row before reloading it.


Title: Re: DataGrid:getSelections vs reload
Post by: mzeddd on April 12, 2014, 05:33:49 AM
Here is small example where this problem is visible

1) Select row #1
2) Click "button1" - get "number of selected rows:1"
3) Click "button2" - no change as soon as DataGrid loads the same data
4) Click "button3" - New data loaded. Row #2 and #3 replaced by #4 and #5. Row #1 still selected
5) Click "button1" - get "number of selected rows:1"
6) Deselect row #1
7) Select row #4
8 ) Click "button1" - get "number of selected rows:1"
9) Click "button2" - selected row #4 disappeared as well as #5
10) Click "button1" - get "number of selected rows:1". We don't have selected rows, but ...



Title: Re: DataGrid:getSelections vs reload
Post by: stworthy on April 12, 2014, 08:31:56 AM
If you do delete rows via background server and don't tell datagrid what rows have been deleted, you need to call 'deleteRow' method to delete what rows to be deleted before reloading new data. Please try the updated example 'index.html'.


Title: Re: DataGrid:getSelections vs reload
Post by: mzeddd on April 14, 2014, 01:48:36 AM
Thanks for answer.

Mixed feelings.

On one hand we may not know what happend in DB. Like somebody removes record but I could still have it as 'selected' and operate with it without knowing that it is not valid anymore. (even if I reload datagrid)

On the other hand paging could be broken. As soon as now it remembers what was selected on previous pages.

As for me I decided to use 'clearSelections' functions where possible as soon as it is the simpliest way in my case.

//V