2012-07-11 96 views
0

我试图绑定dropdownlist(内部jqxgrid单元格)到数据库,但更改事件的dropdownlist(并在同一时间行更新功能)多次工作,然后网格被锁定。 Dropdownlist绑定到具有数据字段“UrunAdi”的列。而且,它是一个asp.net.net mvc3项目。有什么建议?jqxwidgets dropdownlist更改事件(并在同一时间行更新功能)多次工作,然后网格被锁定

代码是:

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' },... 

回答

0

更改列定义为UrunAdi(下拉列表柱):

{ 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。