1

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.

Is there any way to do this either in the column setup or in the custom_element function?

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).

Any suggestions?

Community
  • 1
  • 1
leora
  • 188,729
  • 360
  • 878
  • 1,366

1 Answers1

2

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}});
    }
});
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • 1
    thanks for all your help. This is very close to the right answer but one think i noticed is that if you only set List, it drops the custom_element and custom)_value settings so you have to include those options (just repeat whats in initialization) as well to get it to work. – leora Feb 14 '11 at 01:36