jqGrid,如何从查询中填充选择列表 [英] jqGrid, how to populate select list from query

查看:61
本文介绍了jqGrid,如何从查询中填充选择列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Coldfusion项目中使用了一个基本的jqGrid. 我在jqGrid中的一个字段是组合框.目前,对editoption值进行了硬编码,如下所示.

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.

colModel :
[
  {
   name:'seqnum',index:'seqnum', width:100,resizable:true,   
   align:"left",sorttype:"text",editable:true,edittype:"select",editoptions:   
   { value:"1:one;2:two"},editrules:{required:true}
  }
]

我正在尝试找到一种从查询/URL填充下拉列表的方法.

I am trying to figure out a way to populate the drop-down from a query/url.

任何帮助将不胜感激.

预先感谢

推荐答案

$.getJSON/getSequenceNumbers()的答案无法正常运行.由于回调是异步的,因此无法从回调返回数据作为getSequenceNumbers()的返回值.您要么需要使用Martin建议的dataURL方法,要么在$ .getJSON回调中设置jqGrid.

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}
      }
    ]

...
}

这篇关于jqGrid,如何从查询中填充选择列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆