在jqGrid中,有没有使用Ajax来获取custom_element的数据?

我正在做类似这个问题的事情,我有一个复选框列表作为自定义编辑控件。 区别在于我想从服务器获取我的列表(不是在客户端上使用Check1,Check2,Check3进行硬编码。

有没有办法在列设置或custom_element函数中执行此操作

看起来我需要类似于您用于选择项的dataUrl属性,但这似乎只适用于选择项(不是自定义项)。

有什么建议?

您可以在网格初始化期间使用任何list选项(完全是editoptions选项),然后使用从服务器加载的实际数据覆盖该值:

 $("#list").jqGrid({ colModel: [ {name:'MyMultiCheck',edittype:'custom', editoptions:{custom_element:MultiCheckElem, custom_value:MultiCheckVal,list:''} } ... ] ... }); $.ajax({ url:"getMultiCheckList", // any other parameters like dataType:'json', // type: 'POST' (default type is 'GET') which depend on the server success: function(data){ // the code here depend on the format of data returned from the server // in the simplest situation we have as data already the comma-separated // string which we need as a value for the list parameter so we can do jQuery("#list").setColProp('MyMultiCheck',{editoptions:{list:data}}); } });