0

I'm using two Jqgrids and when I doubleclick on my "main" grid I show another version of the grid. In the new grid I am displaying, I want the row that was selected in the "main" grid to be selected/highlighted.

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%"
                });
            }
        },
ffffff01
  • 5,068
  • 11
  • 52
  • 61
  • Do you use `multiselect: true` in the "main" grid? – Oleg Feb 10 '12 at 09:19
  • Hi, Oleg. No I dont. But I found a solution. loadComplete: function hightlightRow(selrow) { $('#' + id).addClass('ui-state-highlight'); } – ffffff01 Feb 10 '12 at 09:32
  • But over to another subject. How can I get the page of the selected row? – ffffff01 Feb 10 '12 at 09:36
  • because you use *remote* data source (`datetype: 'json'`) you can find the page which need be selected on the server. You can look at [the answer](http://stackoverflow.com/a/3571392/315935) for more details. – Oleg Feb 10 '12 at 16:45

1 Answers1

1

You should use setSelection method to select any row. It's only important the you should do this after the data in the grid are loaded. So you should place the call of setSelection inside of loadComplete or inside of gridComplete callback.

Oleg
  • 220,925
  • 34
  • 403
  • 798