Author Topic: calling addRow but rows not dirty  (Read 2462 times)

[email protected]

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 30
    • View Profile
calling addRow but rows not dirty
« 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

[email protected]

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: calling addRow but rows not dirty
« Reply #1 on: March 15, 2020, 04:28:44 pm »
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) {}
          });
 

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6122
    • View Profile
Re: calling addRow but rows not dirty
« Reply #2 on: March 16, 2020, 09:49:03 am »
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.

Code: [Select]
grid.addNodes( dta.rows, 0 );

https://paramquery.com/pro/api#method-addRow

https://paramquery.com/pro/api#method-addNodes
« Last Edit: March 16, 2020, 10:03:54 am by paramvir »

[email protected]

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: calling addRow but rows not dirty
« Reply #3 on: March 17, 2020, 03:34:46 pm »
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

[email protected]

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: calling addRow but rows not dirty
« Reply #4 on: March 17, 2020, 03:47:15 pm »
calling addRow(rowList, history: true) completely solved my problem. Thanks for a help.