EasyUI Forum
May 12, 2024, 05:49:19 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: How do i batch update partial columns in a datagrid with json data?  (Read 6475 times)
ejzhang
Jr. Member
**
Posts: 61



View Profile
« on: December 05, 2014, 12:20:57 AM »

I have a datagrid with 10 columns, and load some data in it. How do i batch update the columns 1, 2, 5 and 7 with json data, and keep the columns 3, 4, 6, 8, 9, 10?
e.g. The full data:
{"total":3,"rows":[{"Col1":21,"Col2":35,"Col3":27,"Col4":58,"Col5":13,"Col6":25,"Col7":51,"Col8":24,"Col9":23,"Col10":85},{"Col1":23,"Col2":51,"Col3":24,"Col4":85,"Col5":35,"Col6":45,"Col7":36,"Col8":43,"Col9":16,"Col10":65},{"Col1":22,"Col2":38,"Col3":42,"Col4":53,"Col5":85,"Col6":65,"Col7":45,"Col8":86,"Col9":18,"Col10":95}]}
The partial data:
{"total":3,"rows":[{"Col1":26,"Col2":25,"Col5":33,"Col7":62},{"Col1":32,"Col2":46,"Col5":82,"Col7":34},{"Col1":42,"Col2":18,"Col5":73,"Col7":96}]}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 05, 2014, 07:20:00 AM »

Please call 'updateRow' method to change the values of specified columns in one or more rows.
Code:
var data = {"total":3,"rows":[{"Col1":26,"Col2":25,"Col5":33,"Col7":62},{"Col1":32,"Col2":46,"Col5":82,"Col7":34},{"Col1":42,"Col2":18,"Col5":73,"Col7":96}]};

$.each(data.rows, function(index,row){
    $('#dg').datagrid('updateRow', {
        index: index,
        row: row
    });
})
Logged
ejzhang
Jr. Member
**
Posts: 61



View Profile
« Reply #2 on: December 07, 2014, 04:52:46 PM »

Yes, i know, thank you!
A propose, would add a property to the load/reload method of datagrid, it can keep the values of columns that not in json data returned from server.
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!