【问题标题】:How to set highlight on selected row in JqGrid如何在 JqGrid 中的选定行上设置突出显示
【发布时间】:2012-02-10 08:46:03
【问题描述】:

我正在使用两个 Jqgrid,当我双击“主”网格时,我会显示另一个版本的网格。在我正在显示的新网格中,我希望选择/突出显示在“主”网格中选择的行。

ondblClickRow: function (id, rowid) { //function to get value of selected row and show new grid
            var ret = $("#grid1").getRowData(id);
            loadEditGrid(ret.ID);

            function loadEditGrid(id) {
                $("#grid1").empty();
                jQuery("#grid2").jqGrid({
                    url: 'test.json',
                    datatype: "json",
                    jsonReader: {
                        root: 'rows',
                        repeatitems: false,
                        page: "page",
                        total: "total",
                        records: "records",
                        userData: id,
                        cell: "",
                        id: "ID"
                    },
                    colNames: ['Item Name', 'Item Id'],
                    colModel: [{ name: 'ITEM_NAME', index: 'ITEM_NAME', width: 160 },
                                { name: 'ID', index: 'ID', width: 80}],
                height: "75%"
                });
            }
        },

【问题讨论】:

  • 你在“主”网格中使用multiselect: true吗?
  • 嗨,奥列格。不,我没有。但我找到了解决方案。 loadComplete: function hightlightRow(selrow) { $('#' + id).addClass('ui-state-highlight'); }
  • 但是转到另一个主题。如何获取所选行的页面?
  • 因为你使用remote数据源(datetype: 'json')你可以在服务器上找到需要选择的页面。您可以查看the answer了解更多详情。

标签: jquery jqgrid


【解决方案1】:

您应该使用setSelection 方法来选择任何行。唯一重要的是您应该在加载网格中的数据之后执行此操作。所以你应该把setSelection的调用放在loadComplete或者gridComplete回调里面。

【讨论】:

    猜你喜欢
    • 2017-12-14
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-20
    相关资源
    最近更新 更多