jqGrid getLocalRow returning false when data property is set

喜夏-厌秋 提交于 2019-12-08 04:48:31

The problem is in the filling of the grid. Every row of the grid have to get unique id. If your data already have some column with unique data then one can use key: true in the column to inform jqGrid to use the value from the column as the rowid.

I tested last time free jqGrid always with the data, which contains either id property in every column of have key: true property for a column which values one want use as the rowid. If you would follow the rule then the problem which you reports will not exist. See the demo http://jsfiddle.net/OlegKi/y9KHY/92/ which uses the code

$("#submit1").click(function () {
    var $grid = $("#gGrid");
    var grps = [
            { Name : "A",  Group : "11" },
            { Name : "B" , Group : "1122" }
        ];
    $grid.jqGrid({
        data: grps,
        colModel: [
            { name: 'Name', key: true },
            { name: 'Group' }
        ],
        cmTemplate: {width: 200},
        rownumbers: true,
        multiselect: true,
        gridComplete: function () {
            $("#cb_" + this.id).click();
        }
    });
});

$("#submit2").click(function () {
    var $grid = $("#gGrid"), p = $grid.jqGrid("getGridParam"), i;

    for (i = 0; i < p.selarrrow.length; i++) {
        alert("Data  > " + JSON.stringify($grid.jqGrid("getLocalRow", p.selarrrow[i])));
    }
});

The demo http://jsfiddle.net/OlegKi/y9KHY/93/ uses id property in input data.

Nevertheless, the usage of not full input data, without specifying rowid is allowed in general. Thus the described above behavior of free jqGrid is a bug. The bugs is fixed already in the code of free jqGrid on GitHub. You can verify it in the demo http://jsfiddle.net/OlegKi/y9KHY/94/, which uses the code directly from GitHub. I plan publish the next version soon.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!