views:

1765

answers:

2

i have an object with 3 values

  • ID
  • Abbreviation
  • Description

in the jqGrid I set the grid up to display the Abbreviation.

when I click to edit (using the Form Edit feature) I fill the drop down with the ID/Description combination of values via the edit options:

editoptions: { value: "ID1:Description1;ID2:Description2;...;IDN:DescriptionN" }

how can I easily set the selected value in the drop down list, when all I have available to me in the grid is the Abbreviation?

+3  A: 

jqGrid will default a select list to the value in the grid if it can find it, though this obviously doesn't help in your case because the only data jqGrid has to work with is the abbreviation and it's trying to match it to the ID in your select list.

I think the only way you can do this is to include the ID in your grid's colModel as a hidden field. Something like

{name:'ID', hidden:true...}

Then to set the select list to the proper item you need to hook into the beforeShowForm event and use the hidden ID from the currently selected row to set which of your select options is selected by default.

Good luck!

thinkzig
A: 

There's an example buried in the jqGrid forums, you can set the DataURL tag to a text file that contains a select statement. Since it accepts a well formatted select you should be able to set a default.

Martin