Author Topic: Batch Editing - how to update grid recIndx after database insert  (Read 4857 times)

bmais

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 12
    • View Profile
Batch Editing - how to update grid recIndx after database insert
« on: September 27, 2013, 09:43:24 pm »
When I create a new record in the grid it does not have a record_id.  My database insert statement creates and returns it.  How do I update the grid with that record_id?

Note: I do not want to refresh the entire grid - only the new record.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: Batch Editing - how to update grid recIndx after database insert
« Reply #1 on: September 27, 2013, 10:58:33 pm »
Bill

1) keep a reference to the new added record on the client side using rowIndx

2) a) Send the rowData of new record to the server using $.ajax
    b) and get the record_id of the new record (as ajax response) from the server.

3) update the record_id of the client side record using dataModel.data[rowIndx][dataModel.recIndx] = record_id
http://paramquery.com/pro/api#option-dataModel-data

4) use refreshRow() to display record_id in the view 
http://paramquery.com/pro/api#method-refreshRow


Notes:

4th step is optional and required only  if recIndx column is visible in the grid.
If you are doing remote paging, then use rowIndxPage instead of rowIndx

« Last Edit: September 27, 2013, 11:18:52 pm by paramquery »