1

我可以从发布到浏览器的 jqGrid JSON 数据中看到,行 ID(在 JSON 行数据中用“i”表示)正确通过,但是当我进行选择并检查时,$('#list').getGridParam('selarrrow')它显示了所选的行号而不是他们的身份证。

这个事情谁有经验?谢谢

更新

下面是 JSON 结果的图片(复制和粘贴不是一个选项)

(此处为大图)

JSON 结果

以及用于检查选择的 javascript 代码:

<script type="text/javascript">
    function checkSelection(){
        alert($('#list').getGridParam('selarrrow').join());
    }
</script>
4

3 回答 3

4

Justin and Oleg - Im certain that you were put on this planet to solve the world's jQueries :) Thanks again for your assistance with this problem.

SOLUTION
In my code, the grid's column definitions didnt specify a key column from which to draw each row's ID from - how it was getting the i = <id> in the screenshot above, I have no idea, but it definitely wasn't using that ID for each row. I changed the grid definition to the following:

...,
colNames: ['ID', 'Family', 'Variety', 'Type', 'EDI #', 'Colour', 'Swatch'],
colModel: [{ name: 'id', index: 'id', key: true, hidden: true },
...

(notice the key: true in the colModel for the ID column)

于 2010-08-23T08:03:45.403 回答
0

我想从服务器发送的 ID 被忽略,因此行号将是真正的行 ID。您可以使用事件getDataIDs内部的方法来验证这一点。loadComplete为什么ID会被忽略我只能在您发布更多信息时说。

于 2010-07-27T13:41:17.000 回答
0

你确定吗?根据 selrrrow 的jqGrid 文档

此选项是只读的。当 multiselect 设置为 true 时确定当前选择的行。这是一维数组,数组中的值对应于网格中选定的 id。

因此,如果它返回行号,则 jqGrid API 中存在错误。您是否可以发布更多信息,例如您的调用结果selarrrow以及网格中 ID 的完整列表?

于 2010-07-27T13:32:38.477 回答