2

我正在使用 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 });
                }
            }

请帮我。

4

1 回答 1

2

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

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

另见

于 2015-04-22T01:00:44.307 回答