EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kissmoon on December 30, 2014, 12:58:41 AM



Title: How copy rows from a datagrid to other datagrid?
Post by: kissmoon 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);


Title: Re: How copy rows from a datagrid to other datagrid?
Post by: stworthy 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));


Title: Re: How copy rows from a datagrid to other datagrid?
Post by: kissmoon 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)); 


Title: Re: How copy rows from a datagrid to other datagrid?
Post by: stworthy 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);