Author Topic: Updating main grid from detail grid  (Read 2131 times)

KR

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 8
    • View Profile
Updating main grid from detail grid
« on: August 10, 2016, 02:27:24 pm »
I have a main grid with track changes enabled.

In the “cellSave” of the detail grid I update a value in the data of the parent main grid. The new value shows as expected.

However, when doing:

Code: [Select]
var changes = $gridMain.pqGrid("getChanges", {
                    format: 'byVal'
});

Does not return the changes that were made from the detail grid.

It looks like track changes were not triggered. Is it possible to trigger this and how can that be done?

Thank you!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6307
    • View Profile
Re: Updating main grid from detail grid
« Reply #1 on: August 11, 2016, 09:07:33 am »
Following code is in context of this demo: http://paramquery.com/pro/demos/nesting

First of all enable tracking in the main grid.

1) trackModel: {on: true}
2) dataModel.recIndx = "OrderID"

You should use updateRow() method to make changes in the main grid:


Code: [Select]
//cellSave of the detail grid.
cellSave: function(){
var ri = gridMain.getRowIndx({rowData: rowData}).rowIndx;
gridMain.updateRow({
rowIndx: ri,
newRow: {"ShipVia": 'changed'}
})
console.log(gridMain.getChanges());
},

Note: you should be able to see a red triangle in the top left corner of the dirty cells.
« Last Edit: August 11, 2016, 09:09:47 am by paramquery »

KR

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Updating main grid from detail grid
« Reply #2 on: August 11, 2016, 01:57:06 pm »
This works great!

I was not using updateRow(). Instead I updated the rowData directly.

Thank you!