jqGrid, how to populate select list from query

前端 未结 7 1518
盖世英雄少女心
盖世英雄少女心 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:39

    Create a function that uses json to query the url. This function should return a string in the format "1:one;2:two".

    For example:

        colModel :
        [
          {
           name:'seqnum',index:'seqnum', width:100,resizable:true,   
           align:"left",sorttype:"text",editable:true,edittype:"select",editoptions:
           { value:getSequenceNumbers()},editrules:{required:true}
          }
        ]
    
        function getSequenceNumbers(){
            $.getJSON("yourUrl", null, function(data) {
                if (data != null) {
                     //construct string.  
                     //(or the server could return a string directly)
                }
            });
        }
    

    I suppose you could put the function inline as well, but I think it would be harder to read.

提交回复
热议问题