EasyUI Forum
May 09, 2024, 11:16:04 AM *
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 scrollview breaks updateRow due to getRows  (Read 13971 times)
tomhj
Newbie
*
Posts: 40


View Profile
« on: December 07, 2013, 09:55:15 AM »

I'm using the scrollview view for virtual scrolling through a large dataset.  I need to update a row using the updateRow method which takes an index and the new row data.

What I'm finding is this works fine for the first page full of rows (first 40 rows), but as soon as I try to update a row in a subsequent page (say row 45), I get errors inside scrollview's renderRow method.  I tracked it down in a debugger to a problem with datagrid's getRows method only returning the first page full of rows - only the first 40 it seems.  But rowIndex is 45 so a reference to rows[rowIndex] causes problems.

I think what is needed is for the datagrid to support a getRow method that takes the index and returns the row of data.  Relying on getRows[rowIndex] to get the row doesn't work when virtual paging is used.  getRow would need to call into the view to get the data row.  Clearly there are two cases:  a) row is present in the current page of data and b) row is not.  First case is easy, second is not because it would involving a request to fetch the page of rows containing the requested rowIndex - which of course would not be synchronous.

Is there another way to do this that I'm not seeing?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 07, 2013, 07:04:04 PM »

Please refer to this example http://jsfiddle.net/cQTe6/. Select a row and click the 'UpdateSelectedRow' button, you will see the 'name' field value of selected row is updated to 'updatedname'.
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #2 on: December 08, 2013, 12:38:46 AM »

That only works because the loadData call passes the entire array of 8,000 rows.

I changed the example to hook up a real backend using the 'url' property to fetch the data one page of 50 rows at a time.  After row 50, it does not work anymore.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 08, 2013, 03:38:51 AM »

Please visit this example http://www.jeasyui.com/tutorial/datagrid/datagrid27_demo.html. Select a row and run the code below on the 'Console' panel of browser, it works fine.
Code:
var dg = $('#tt');
var row = dg.datagrid('getSelected');
if (row){
var index = dg.datagrid('getRowIndex', row);
dg.datagrid('updateRow',{
index:index,
row:{name:'updatedname'}
});
}

Be sure you are using the newest scroll view file. If not, download it from http://www.jeasyui.com/extension/datagridview.php and include it into your page.
Logged
tomhj
Newbie
*
Posts: 40


View Profile
« Reply #4 on: December 13, 2013, 07:28:01 PM »

Finally got back to working on this...

The problem turned out to be fixed in the latest scrollview.

Thanks,
Tom
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!