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

I am doing something similar to this question where I have a list of checkboxes as a custom control. The difference is that I want to get my list from the server (not hardcoded on the client with Check1, Check2, Check3 .

Is there a way to do this either in the column setting or in the custom_element function?

It seems to me that I need something similar to the dataUrl property, which you use for individual elements, but it seems that it applies only to individual elements (and not to ordinary ones).

Any suggestions?

+1
source share
1 answer

You can use any list option (to be exactly editoptions ) during grid initialization, and then overwrite the value with 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}}); } }); 
+2
source

Source: https://habr.com/ru/post/897947/


All Articles