i load data via ajax call in datainit works , works fine none of columns (only dropdown columns) don't set id value.
e.g. have itemid , itemcode properties. load data , displays correctly if change value in drop down doesn't bind/update itemid value.
essentially want dropdown bind id column when saving id save.
,{ key: false, hidden: true, name: 'itemid', index: 'itemid', editable: false }, { key: false, name: 'itemcode', index: 'itemid', editable: true, edittype: 'select', editoptions: { datainit: function(element) { $.ajax({ url: '@url.action("getitems", "maintenance")', datatype: 'json', type: 'post', success: function(response) { var array = response; if (array != null) { var i; (i in array) { if (array.hasownproperty(i)) { if (itemid == array[i].id) { $(element).append("<option value=" + array[i].id + " selected>" + array[i].code + "</option>"); } else { $(element).append("<option value=" + array[i].id + ">" + array[i].code + "</option>"); } } } } } }); } }, editrules: { required: true}
here answer.....look @ data events. find selected row , set cell. console log test.
{ key: false, hidden: true, name: 'userid', index: 'userid', editable: false }, { key: false, name: 'username', index: 'username', editable: true, edittype: 'select', editoptions: { datainit: function(element) { $.ajax({ url: '@url.action("getusers", "maintenance")', datatype: 'json', type: 'post', success: function(response) { var array = response; if (array != null) { var i; (i in array) { if (array.hasownproperty(i)) { if (userid == array[i].id) { $(element).append("<option value=" + array[i].id + " selected>" + array[i].username + "</option>"); } else { $(element).append("<option value=" + array[i].id + ">" + array[i].username + "</option>"); } } } } } }); }, dataevents: [ { type: 'change', fn: function (e) { var rowid = $("#jqgrid").jqgrid('getgridparam', 'selrow'); $('#jqgrid').jqgrid('setcell', rowid, 'userid', $(e.target).val()); console.log($("#jqgrid").jqgrid('getcell', rowid, 'userid')); } } ] }
Comments
Post a Comment