EasyUI Forum
November 02, 2025, 05:57:15 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: DataGrid:getSelections vs reload  (Read 14372 times)
mzeddd
Full Member
***
Posts: 223



View Profile
« 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

« Last Edit: April 11, 2014, 02:10:33 AM by mzeddd » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #2 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 ...

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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'.
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #4 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!