View Full Version : how to best handle updates from detail to the master table

20 Dec 2006, 2:35 PM
I posted some questions in a thread which was categoried under "Feature Requests" but I think it deserves a new thread.

In the master detail grid, when I select say the second row and then update the details, I want the details to be updated in grid too. I'm presently relaoding the grid after I save the detail but as a result the selection in the grid gets reset to the first row, consequently causing the detail to switch as well.

Are you preserving the user's original selection when the detail is saved? If so, how are you handling this? Also what if the user adds a new row in a paged table when the user is viewing page 1 (of 3). The new record would be added to the end so I'm not sure how best to handle this. Should we go to page 3 with the newly added record selected? It doesnt seem the best solution.

Other options I'm considering are :

1. Show details on row roubleclick as opposed to selection model 'rowselect'. The user interaction would still a little confusing if he edited an existing record and saved it as the table selection would go to the first row while the details would a) either be reset to row 1's detail or b) remain the details of the edited row.

2. On edit of existing row, manually update the grid's data model too. This behavior would probably be what the user expects. For newly added rows, the just go to the end and may not be visible if the user is on page 1 (of 3). I think this is what Jacks XML Binding example does but the complication this introduces is the grid model is updated by the detail and to propagate the changes from the grid to the server, the data model contents need to be posted and the server may end up requiring to update all rows, even though only one might have changed. Either that, or additional book keeping would be required in the XMLDataModel to track state changes (which may get messy?)

In my use case, not all 'details' are dispalyed in the grid. Only some of the fields are dispalyed in the master table.

If all fields were present in the grid, I could just use and editable grid.

Comments or suggestions appreciated.


21 Dec 2006, 1:01 AM
Updating the Detail Region from the Grid selection is quite easy. My ListManager object has an Array of ContentPanels that have been added to the Detail Region. On the Grid's "rowselect" event, it just calls refresh() on each one. The URL of each ContentPanel is a function which is able to query the state of the Grid to create the URL string to get the right resource.

Updating the Grid Region when the Detail Region has been updated?

I've not looked at this yet. The boss became nervous about how much time I was spending writing the ListManager, so that bit isn't done.

For updating a row, I definitely would not refresh the whole Grid, just the single row in the DataModel, and that fires the appropriate events so that the View updates itself.

For adding rows, it depends how the Grid was created. It may be that the new row falls outside the query. If it is in the query, it may be at any position. Here, I think you have to re-issue the query, and refresh the Grid. If the new row is outside the criteria for the query, then tough luck - the user specified what they were looking for - they can requery.

For deletions, just delete from the DataModel, and fire the event.

Well, that's my theory, but as I say, I've yet to do that part!

22 Dec 2008, 3:27 AM
hi, do you have sample for this? Thanks