In jqGrid, is there anyway to use Ajax to get data for your custom_element?

前端 未结 1 427
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-07 07:43

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

1条回答
  •  再見小時候
    2021-01-07 08:43

    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}});
        }
    });
    

    0 讨论(0)
提交回复
热议问题