0
我通過dataInit中的ajax調用加載數據,它的工作原理和一切正常,但沒有我的列(只有下拉列)不設置id值。jqGrid選擇不更新onchange(C#MVC)
例如我有itemId和itemCode屬性。我加載數據並正確顯示,但如果我更改下拉列表中的值,那麼它不會綁定/更新我的itemId值。
基本上我想下拉列表綁定到我的ID列,因此當保存它我得到一個ID保存。
,{
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;
for (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}