【问题标题】:How to show Dropdownlist on page load in Jqxgrid如何在 Jqxgrid 中的页面加载时显示下拉列表
【发布时间】:2015-04-21 13:55:54
【问题描述】:

我正在使用 jqwidgets 的 Jqxgrid。

我在一个网格中做了一个下拉列表。

我想在页面加载时默认以可编辑模式显示下拉列表。

请看一下这个屏幕截图,其中第一个下拉菜单显示为“请选择”,它是点击网格单元格,默认如何绑定它。

下面是代码。

{
                text: 'Position of meter in Rack', datafield: 'MeterPositionInRack', width: 180, columntype: 'dropdownlist', editable: true,
                createeditor: function (row, column, editor) {
                    var list = ['1', '2', '3' ,'4'];
                    editor.jqxDropDownList({ autoDropDownHeight: true, source: list, selectedIndex: 0 });

                    editor.jqxDropDownList.bind('select', function (event) {
                        var args = event.args;
                        var item = $('#jqxdropdownlist').jqxDropDownList('getItem', args.index);
                        alert('Selected: ' + item.label);
                    });
                }
                , initeditor: function (row, cellvalue, editor) {
                    var list1 = ['1', '2', '3', '4'];
                    console.log("initeditor: " + list1);
                    editor.jqxDropDownList({ autoDropDownHeight: true, source: list1, selectedIndex: 0 });
                }
            }

请帮帮我。

【问题讨论】:

    标签: jquery asp.net-mvc jqxgrid jqxwidgets


    【解决方案1】:

    jqxgrid有ready属性在grid初始化绑定完成后可以做任何事情,所以可以触发begin update方法:

    $("#jqxgrid").jqxGrid({
     ...
     ready: function () {
              $("#jqxgrid").jqxGrid('beginrowedit', 0);
          },
     ...
     });
    

    另见

    【讨论】:

    • 感谢荣的回复,单行有效,如何申请全行,请看jsfiddle.net/e3m2L11t/6
    • aah.. 谢谢荣它很好...:)
    猜你喜欢
    • 2014-05-24
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 1970-01-01
    • 2015-07-28
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多