在jqGrid的,反正是有使用Ajax来获得数据的custom_element? [英] In jqGrid, is there anyway to use Ajax to get data for your custom_element?
问题描述
我做的事情<一href="http://stackoverflow.com/questions/2825000/jqgrid-multi-checkbox-custom-edittype-solution">similar对这个问题在那里我有复选框作为一个自定义编辑控件列表。不同的是,我希望得到我的列表从服务器(不硬codeD中的客户机上的检查1,CHECK2,Check3
I am doing something similar to this question where I have a list of checkboxes as a custom edit control. The difference is that I want to get my list from the server (not hard coded on the client with Check1, Check2, Check3.
有没有办法做到这一点无论是在列设置或在 custom_element 的功能?
Is there any way to do this either in the column setup or in the custom_element function?
好像我需要类似的 dataUrl 您使用的选择项目,但似乎只适用于选择项目(非定制的)属性。
It seems like I need something similar to the dataUrl property that you use for select items but that seems to only apply to select items (not custom ones).
有什么建议?
推荐答案
您可以使用任何列表
选项(要完全 editoptions $在网格初始化,然后与从服务器加载的真实数据覆盖值c $ C>):
You can use any list
option (to be exactly editoptions
) during the grid initialization and then overwrite the value with the real data loaded from the server:
$("#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}});
}
});
这篇关于在jqGrid的,反正是有使用Ajax来获得数据的custom_element?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!