我正在尝试将下拉列表(在 jqxgrid 单元格内)绑定到数据库,但是下拉列表的更改事件(以及同时行更新功能)多次工作,然后网格被锁定。下拉列表绑定到具有数据字段“UrunAdi”的列。而且,它是一个 asp .net mvc3 项目。有什么建议吗?
代码是:
var gridSource = {
datatype: "json",
datafields: [{ name: 'KargoId' }, { name: 'Ad' }, { name: 'Soyad' }, { name: 'UrunAdi' }, { name: 'UrunId', type: 'int' }, { name: 'Uygunluk', type: 'boolean' },
{ name: 'YuklenmeTarihi', type: 'date' }, { name: 'Adet' }, { name: 'Fiyat'}],
url: 'BindGrid',
updaterow: function (rowid, rowdata) {
var data = $.param(rowdata);
//alert(data);
$.ajax({
dataType: 'json',
url: 'UpdateEditGrid',
data: data,
success: function (data, status, xhr) {
// update command is executed.
}
});
}
};
var gridDataAdapter = new $.jqx.dataAdapter(gridSource, {
downloadComplete: function (data, status, xhr) { },
loadComplete: function (data) { $("#jqxgrid").jqxGrid('hidecolumn', 'UrunId'); },
loadError: function (xhr, status, error) { alert(JSON.stringify(xhr)); }
});
var dropdownSource = {
datatype: "json",
datafields: [{ name: 'UrunId' }, { name: 'UrunAdi'}],
url: 'BindDropdown'
};
var dropdownListAdapter = new $.jqx.dataAdapter(dropdownSource, { autoBind: true, async: false });
// initialize jqxGrid
$("#jqxgrid").jqxGrid(
{
width: 670,
source: gridDataAdapter,
editable: true,
theme: theme,
selectionmode: 'singlecell',
columns: [
{ text: '#', datafield: 'KargoId', width: 40 },
{ text: 'Ad', columntype: 'textbox', datafield: 'Ad', width: 90 },
{ text: 'Soyad', datafield: 'Soyad', columntype: 'textbox', width: 90 },
{ text: 'Urun', columntype: 'dropdownlist', datafield: 'UrunAdi', width: 177,
initeditor: function (row, cellvalue, editor) {
var urunId = $('#jqxgrid').jqxGrid('getcellvalue', row, "UrunId");
editor.jqxDropDownList({ displayMember: 'UrunAdi', source: dropdownListAdapter, selectedIndex: urunId });
editor.bind('change', function (event) {
var selectedUrunId = editor.jqxDropDownList('getSelectedIndex');
$('#jqxgrid').jqxGrid('setcellvalue', row, "UrunId", selectedUrunId);
});
}
},
{ text: 'UrunId', datafield: 'UrunId' },...