ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: kshipra on December 01, 2017, 09:03:03 am
-
For new rows , users want to copy existing rows and modify them.
so I am adding new rows from existing rows selected.
There are 2 problems with this code:
1. New rows when modified, there are same entries in addList and updateList. - I want entry only in addList
2. When pasting is done on cell new rows , existing rows cells also show modified sign but they are modified. - I have no idea why that is happening.
Any help ?
function cloneRows() {
var arr = $grid.pqGrid("selection", { type: 'row', method: 'getSelection' });
console.log("getRowIndx");
console.log(arr);
if (arr && arr.length > 0) {
for (var index = 0; index < arr.length; index++) {
var foo = arr[index].rowData;
var clone = Object.assign({}, foo);
clone.Id = -index;
clone.pq_rowcls = 'yellow';
var addIndx = $grid.pqGrid("addRow", { rowIndx: index, rowData: clone, checkEditable: false });
console.log("addIndx");
console.log(addIndx);
}
$grid.pqGrid("setSelection", null);
$grid.pqGrid("refresh");
}
else {
alert("Select a row.");
return null;
}
}
-
For new rows , users want to copy existing rows and modify them.
so I am adding new rows from existing rows selected.
There are 2 problems with this code:
1. New rows when modified, there are same entries in addList and updateList. - I want entry only in addList
2. When pasting is done on cell new rows , existing rows cells also show modified sign but they are not modified and they still have existing value. - I have no idea why that is happening.
Any help ?
function cloneRows() {
var arr = $grid.pqGrid("selection", { type: 'row', method: 'getSelection' });
console.log("getRowIndx");
console.log(arr);
if (arr && arr.length > 0) {
for (var index = 0; index < arr.length; index++) {
var foo = arr[index].rowData;
var clone = Object.assign({}, foo);
clone.Id = -index;
clone.pq_rowcls = 'yellow';
var addIndx = $grid.pqGrid("addRow", { rowIndx: index, rowData: clone, checkEditable: false });
console.log("addIndx");
console.log(addIndx);
}
$grid.pqGrid("setSelection", null);
$grid.pqGrid("refresh");
}
else {
alert("Select a row.");
return null;
}
}
-
When cloning rows, care should be taken to remove the primary key field (set it to undefined ) before adding them to pqgrid.
Also existing rows have meta data associated with them which should not be copied, so individual fields ( dataIndx ) should be copied from existing rows instead of copying everything from them.