你可以使用任何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}});
}
});
感謝你的幫助。這是非常接近正確的答案,但我想到的一個問題是,如果你只設置列表,它會刪除custom_element和custom_value設置,所以你必須包含這些選項(只需在初始化中重複什麼)以及它工作。 – leora 2011-02-14 01:36:48