views:

130

answers:

1

Hi,

I have utilised the example code at Example Code at this link

and I have got my grid to show a dynamically constructed select dropdown on add and edit. However when it is just showing the data in the grid it shows the dropdown index instead of its associated data. Is there a way to get the grid to show the data associated with the index instead of the index itself.

e.g. the data on my select could be "0:Hello;1:World"; The drop down on the edit/add window is showing Hello and World and has the correct indexes for them. If the cell has a value of 1 I would expect it to show World in the grid itself but it is showing 1 instead.

Here is the row itself from my grid:

{ name: 'picklist', index: 'picklist', width: 80, sortable: true, editable: true,
  edittype: "select", formatter: "select", editrules: { required: true} },

I am filling the dynamic data content in the loadComplete event as follows:

$('#mygrid').setColProp('picklist', { editoptions: { value: picklistdata} });

picklist data is a string of "0:Hello;1:World" type value pairs.

Please can anyone offer any help. I am fairly new to JQGrids so please could you also include examples.

A: 

If you save in jqGrid ids of the select elements and want to show the corresponding textes then you should use formatter:'select' in the colModel (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter#formatter_type_select) together with the edittype: "select".

The Usage of stype: 'select' could be also interesting for you if you plan to support data searching.

Oleg
Thank you for the information but I have already tried this. In the end I had to reformat my SQL to being back the data instead of the ID for the gird cell. I would of thought that a row of type select would use the ID in the datasource as an index into the list of the select but I guess it doesn't work like that after all, or maybe its a fault with the dynamically filled Select types.
EnterpriseMonkey