Author Topic: master detail reset  (Read 4385 times)

versatile1964

  • Newbie
  • *
  • Posts: 2
    • View Profile
master detail reset
« on: February 18, 2014, 12:03:30 pm »
How do I reset my detail grid, say with the first row key from my master grid from a combo box change event?  I've followed the examples and can load the master grid fine. The master grid row select also loads the detail fine...

I started running into issues when I wired up a combo box that I use filter out records on my master grid - that also works fine and I can filter and load the data I want.  However, in that combo box change event, I want to either set the detail grid to no records say (ie. make sure it is not displaying the previous master grid selection detail results)...or preferably load the detail grid by default with the first row key from my master grid...

It is unclear to me though how to accomplish that...how to trigger the master row select from a different event...and in the change event of my combo box, the master refresh does not complete in that event (thus it does not appear that I can call the select row at that point from what I can see)...so I don't know how to fire the row select event problematically say passing row 0 by default...

load page combo box defaults to All master records
  master loads
  detail is empty
select master row (say key type = foo
 detail  loads foo details

select combo choice (type=bar)
master loads all records of type bar
detail still shows foo details <<   I want to reset detail grid or show first details per master row key 0...

Thanks

sidads

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: master detail reset
« Reply #1 on: February 18, 2014, 02:24:22 pm »

Hi,

If I understand your question correctly then I had similar scenario and below is what I used to reset the child grid

Please check my code at jsfiddle

http://jsfiddle.net/sidads/3Ws9g/4/


Basically pass empty Data to Data Model and Refresh the grid like below

Code: [Select]
    $("#grid").pqGrid( "option" , "dataModel.data",[] );
$("#grid").pqGrid("refresh");


Hope this helps

Regards,
Sidads

versatile1964

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: master detail reset
« Reply #2 on: February 19, 2014, 03:56:48 am »
First of all thanks for feedback.

I decided to go with setting the detail to a default first row of master...and got things working by cleaning up how I was storing my master grid selected key...on the row select event I store my key, and I do a detail grid refresh in the master getdata.  In the detail getdata, I can then check if a current page row is selected (ie. master row clicked)...otherwise I get the current master data and set my details with the first row results...
In my combo box change event...I make sure to unselect rows...this works fine except for scenario where user clicks an editable cell, leaves it there and then click the combo (I may post shortly on that since I do not see how to check if a cell is selected...row sure, but cell no)...this would effectively break saving data so I think there is some notes on using the onblur.

I'll post some code snippets once I make sure it works cleanly.

djm