I am adding new rows by selecting existing rows. The problem is first time it creates empty blank row but then it adds new rows from existing data rows and works properly.
I do not understand why it is creating blank row for first time? Need help.
var arr = $grid.pqGrid("selection", { type: 'row', method: 'getSelection' });
// console.log(arr);
if (arr && arr.length > 0) {
var colModel = $grid.pqGrid("getColModel");
for (var index = 0; index < arr.length; index++) {
// var foo = arr[index].rowData;
/* console.log("arr[index].rowData");
console.log(arr[index].rowData);
console.log(foo);*/
// var clone = Object.assign({}, foo);
var clone = {};
for (var i = 0; i < colModel.length; i++)
{
var column = colModel[i];
//console.log(column.dataIndx);
if (column.dataIndx === "Id") {
console.log("Id match");
continue;
} else {
clone[column.dataIndx] = arr[index].rowData[column.dataIndx];
console.log(clone[column.dataIndx]);
}
}
clone.pq_rowcls = 'yellow';
clone.Deprecated = false;
clone.IsTemplate = false;
clone.Exclude = false;
console.log("clone");
console.log(clone);
delete clone.Id;
console.log("remove Id from clone");
var addIndx = $grid.pqGrid("addRow", {rowIndx: index, rowData: clone, checkEditable: true });
$grid.pqGrid("setSelection", null);
$grid.pqGrid("refresh");
}
}