Is it possible to merge the Column Model javascript file and the raw data JSON response into 1 file?
Oleg – here you go:
JSON – codes.json
{
"codes":[
{
"code" : "WFH - Work From Home"
},
{
"code" : "OST - Onsite"
}
]}
dataUrl and buildSelect – this is drawing up an empty select box
editoptions: {
dataUrl: 'http://localhost/json/codes.json',
type: "GET",
dataType: "json",
contentType: "application/x-javascript; charset=utf-8",
async: "true",
buildSelect: function(response){
var s = '<select>';
$.each(response.codes, function(index, codes){
s.append("<option>"+codes.code+"</option>");
});
return s + '</select>';
}
}},
You should modify the code of
buildSelectto about the followingAdditionally you should use
ajaxSelectOptionsto set any options of the corresponding$.ajaxrequest which you jqGrid if it get data from from the server. In any way you should use relative URLs likejson/codes.jsonor/json/codes.jsoninstead ofhttp://localhost/json/codes.json.An example of
ajaxSelectOptionsparameter could be the followingIf
contentType: "application/x-javascript; charset=utf-8"is really required you can add it as additional property ofajaxSelectOptions.How you can see from the demo the selects will be produced correct from your JSON data by above
buildSelectfunction. The select looks like