I am using setColProp to dynamically load values into a select edittype.
I have the values successfully load whenever I call:
loadComplete: function() {
$("#profile_table").setColProp('contract_num', { editoptions: { value: contract_list} });
},
However it only works here, and only once. If I change the value of contract_list and try to update the jqgrid by calling
$("#profile_table").setColProp('contract_num', { editoptions: { value: contract_list} });
again from anywhere (from a button click, from afterSubmit, or even reloading table) it does nothing at all.
Is there something that I’m doing wrong?
edit:
Here is a better explanation of what I’m trying to do.
I have a jqGrid table with the id #profile_table.
This is part of the colModel in the jqGrid code:
colModel:[
{name:'contract_num',index:'contract_num', editable: true, hidden: false, width:30, edittype: "select", editrules: {required: true}},
]
Initially the contract_num edit field in the edit/add forms has no values in its select box. I load initial values from a javascript variable called contract_list that is created before the table gets created. I load these values initially by using:
loadComplete: function() {
$("#profile_table").setColProp('contract_num', { editoptions: { value: contract_list} });
},
This works fine, however it is possible that the values of contract_list will change whenever a user changes something else on the page that this table is displayed on. So I am trying to dynamically update the options inside of the select box for the contract_num field inside of the edit/add forms for this table. I successfully change the values inside of contract_list, however I cannot get the actual select box to update to the new values.
I am trying to update it by calling:
$("#profile_table").setColProp('contract_num', { editoptions: { value: contract_list} });
and then reloading the grid whenever someone changes the values for contract_list, however the table is not being updated.
I think your main problem will be solved if you would use recreateForm: true options of the form editing (see here an example of the usage). I recommend you to set the setting as the default before you call
navGrid(see here the corresponding code).Moreover from the information which you wrote in comments I think that you should better use
dataUrlinstead ofvalueof the editoptions. So jqGrid can loads the list of the values directly from the server during creating of the edit form. Sometimes the usage ofbuildSelectis useful. It help you to provide the data from the server in for example JSON format and construct the<select><option value="...">...</option>...</select>HTML fragment based on the server data inside ofbuildSelect. Additionally it could be required to setajaxSelectOptions: { cache: false }jqGrid option (see here or here) or to force re-validation of the previous server response on thedataUrlwith respect of HTTP header"Cache-Control: private, max-age=0"(see here and here)