EasyUI Forum
April 30, 2024, 07:16:41 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 copy rows from a datagrid to other datagrid?  (Read 6575 times)
kissmoon
Newbie
*
Posts: 25


View Profile
« on: December 30, 2014, 12:58:41 AM »

copy rows from a datagrid to other datagrid,
please see the attachment for detail.

there are the code:
            var row = $('#dg').datagrid('getRows');
            var jsonObject = JSON.stringify(row);
            var ndg = $('#newdg').datagrid();
            ndg.datagrid('loadData', jsonObject);
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 31, 2014, 01:18:03 AM »

Please try this:
Code:
var rows = $('#dg').datagrid('getRows');
var ndg = $('#newdg').datagrid();
ndg.datagrid('loadData', $.extend(true,[],rows));
Logged
kissmoon
Newbie
*
Posts: 25


View Profile
« Reply #2 on: December 31, 2014, 01:36:05 AM »

OK,thanks.
By the way, which document or other , I can get like this method and use it.          ndg.datagrid('loadData', $.extend(true,[],rows)); 
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: December 31, 2014, 01:46:44 AM »

The statement $.extend(true,[],rows) deep copy an array. The code below also works well but these two datagrid components use the same data rows.
Code:
var rows = $('#dg').datagrid('getRows');
var ndg = $('#newdg').datagrid();
ndg.datagrid('loadData', rows);
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!