jqxwidgets下拉列表更改事件(同时行更新功能)工作多次,然后网格被锁定



我正试图将dropdownlist(在jqxgrid单元格内)绑定到数据库,但dropdownlib的更改事件(同时还有行更新功能)工作了多次,然后网格被锁定。Dropdownlist绑定到数据字段为"Uruandi"的列。而且,它是一个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' },...

我将UruanDI的列定义(下拉列表列)更改为:

 { 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) {
                          selectedUrunId = editor.jqxDropDownList('getSelectedIndex');
                      });
                  }
              }

只有一个区别:

删除$('#jqxgrid').jqxGrid('setcellvalue', row, "UrunId", selectedUrunId);我认为,"setcellvalue"事件触发了updaterow。

最新更新