JqGrid editor: 'select, formatter:' select 'not working

I am using JSON to retrieve values โ€‹โ€‹for a select element.
my colModel :

 { name: 'position', editable: true, edittype: "select", formatter:'select', editoptions: { value: function() { var positions; $.ajax({ url: "orthofixServices.asmx/GetPositionsList", data: "{}", async: false, success: function(data) { positions = data.d; }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); } }); return positions; } 

this is the answer:

 { "d": { "21": "CAP Pos 1", "41": "CAP Pos 2", "42": "CAP Pos 3" } } 

And the line sent from the server to snap the grid,

 { "d": { "page": 1, "total": 1, "records": 1, "rows": [ { "id": 9, "name": "Julio", "nameid": 0, "title": "Doctor", "npi": "123-123", "license": "licabc", "licstate": "NV", "position": "41", "us": false, "hrate": 0, "rrate": 0 } ] } } 

"position" is a field from a string that passes a select element. After saving the line on the grid, nothing is displayed. What for? Should I save the key from select as Int or as String . Does it matter? I tried both ways so that I could never display anything in the grid for the select element. He should show: "CAP Pos 42"

+4
source share
2 answers

I would recommend using the dataUrl and buildSelect properties. In addition, you will need to set some properties of the ajaxSelectOptions option for jqGrid.

See here , here and here for usage examples.

+1
source

The simple sad fact is that

 formatter:'select', editoptions: { value: function() { ... 

jqGrid is not implemented. The source code for $.unformat.select just does not handle this case. Just convert the data to an array and pass it to the function via value to get the same effect.

+1
source

Source: https://habr.com/ru/post/1400627/


All Articles