jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Copy the selected rows below of it
This topic contains 3 replies, has 1 voice, and was last updated by RajaniKantaPanda 13 years ago.
-
Author
-
Hi , I want to copy the selected rows just below of it but not able to do.Copy is nothing but addrow to the grid.So copy (addrow) is happening either the 1st row or last row(means if 100 records are there then the position of addrow will be after 100 row) of the grid. Can u check my code please?
$(“#CopyRow”).jqxButton({ width: ‘110’, height: ’25’ });
$(“#CopyRow”).bind(‘click’, function () {
debugger;var selectedrowindexs = $(“#jqxgrid”).jqxGrid(‘selectedrowindexes’);
var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
var id = $(“#jqxgrid”).jqxGrid(‘getrowid’, selectedrowindex);
var nextrow = id + 1;var row = [];
for (var i = 0; i < selectedrowindexs.length; i++) {
row[i] = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindexs[i]);
$("#jqxgrid").jqxGrid('addrow', null, row[i], nextrow);
//$("#jqxgrid").jqxGrid('addrow', null, row, nextrow);
}});
For reference attaching the image of the output of the code.I copied 4th and 5th row .But adding only 4th row 2 times.Please check.
Sorry. image is
I want to add just below the selected rows.If i am doing below code the then datas are adding in first two rows(if i am selecting 2 rows for copy) .How can i add just below of the selected row?
$(“#CopyRow”).jqxButton({ width: ‘110’, height: ’25’ });
$(“#CopyRow”).bind(‘click’, function () {
debugger;var selectedrowindexs = $(“#jqxgrid”).jqxGrid(‘selectedrowindexes’);
var selectedrowindex = $(“#jqxgrid”).jqxGrid(‘getselectedrowindex’);
var id = $(“#jqxgrid”).jqxGrid(‘getrowid’, selectedrowindex);
var nextrow = id + 1;var row = [];
for (var i = 0; i < selectedrowindexs.length; i++) {
row[i] = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindexs[i]);//$("#jqxgrid").jqxGrid('addrow', null, row, nextrow);
}
//$("#jqxgrid").jqxGrid('addrow', null, row);
for (var j = 0; j < row.length; j++) {
$("#jqxgrid").jqxGrid('addrow', selectedrowindexs, row[j], nextrow+j);
}
});I have done that.
We need to change
if(d==”last”){this.records.push(h)}else{this.records.splice(d,0,h)}
in jqxgrid.js file
previously it was
if(d==”last”){this.records.push(h)}else{this.records.splice(0,0,h)}Thanks.
-
AuthorPosts
You must be logged in to reply to this topic.