首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jqxwidgets dropdownlist change事件(同时还有行更新函数)多次工作,然后网格被锁定

jqxwidgets dropdownlist change事件(同时还有行更新函数)多次工作,然后网格被锁定
EN

Stack Overflow用户
提问于 2012-07-11 08:35:57
回答 1查看 5.6K关注 0票数 0

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

代码为:

代码语言:javascript
复制
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' },...
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-07-11 23:11:29

我将UrunAdi (dropdownlist列)的列定义改为:

代码语言:javascript
复制
 { 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。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11423954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档