ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: jkoci@volny.cz on March 14, 2020, 07:27:50 pm
-
Hello,
I am adding rows programmatically
//set grid data
$.each(dta.rows, function(i,item) {
console.log(item);
grid.addRow({ rowIndxPage: 0, rowData: item, checkEditable: false, history: true });
});
having trackModel.on=true, dataModel.recIndx correctly set, but after adding rows there is no "dirty" redflag.
After editing any added row and change value, dirty flag appears correctly.
What is missing to make added rows dirty?
THX,
Jan
-
update: I made this disgusting hack which bring desired behavior, but not solved the reason
//set grid data
$.each(dta.rows, function(i,item) {
var rowIndx=grid.addRow({ rowIndxPage: 0, newRow: {pKey: item.pKey, detail: item.detail, valEnd: item.valEnd, rowState: item.rowState}, checkEditable: false, history: false });
//this is a nasty hack - grid does not indicate added rows dirty
//but calling updateRow ends with exception :--(
try {
grid.updateRow({ rowIndx: rowIndx, newRow: {pKey: item.pKey, detail: item.detail, valEnd: item.valEnd, rowState: item.rowState}, checkEditable: false, history: true });
}
catch (e) {}
});
-
New rows are not considered dirty and don't have any dirty red flag by design.
If you want to make new rows appear visually different from other rows, you can add style / class to new rows.
------
BTW calling addRow method multiple times in a loop is not good for performance.
You can either build the rowList in the loop and call addRow() only once at end of loop
or use easier addNodes method without need of a loop.
grid.addNodes( dta.rows, 0 );
https://paramquery.com/pro/api#method-addRow
https://paramquery.com/pro/api#method-addNodes
-
Paramvir,
thank you, for making it more clear.
Is there any way how to put added rows into undo history in order to indicate something is changed?
Thanks,
Jan
-
calling addRow(rowList, history: true) completely solved my problem. Thanks for a help.