jqGrid, how to populate select list from query

前端 未结 7 1521
盖世英雄少女心
盖世英雄少女心 2021-01-02 20:02

I got a basic jqGrid working in my coldfusion project. One of my fields in jqGrid is a combo box. Currently the editoption values are hard coded just like below.

<         


        
7条回答
  •  没有蜡笔的小新
    2021-01-02 20:35

    The $.getJSON / getSequenceNumbers() answer does not work as presented. There is no way to return data from a callback as the return value for getSequenceNumbers() because the callback is asynchronous. You either need to use the dataURL method suggested by Martin or setup the jqGrid inside of the $.getJSON callback.

    $(document).ready(function() {
     $.getJSON("GetURL", function(data) {
      setupGrid(data);
     });
    });
    
    function setupGrid(data) {
    ...
        colModel :
        [
          {
           name:'seqnum',index:'seqnum', width:100,resizable:true,   
           align:"left",sorttype:"text",editable:true,edittype:"select",editoptions:
           { value:data},editrules:{required:true}
          }
        ]
    
    ...
    }
    

提交回复
热议问题