-1

我正在创建一个表单,它将基于 XML 数据显示多个网格(4 个标准网格和 1 个子网格)。到目前为止,在我的所有测试中,一切正常。我已经能够使用 getRowData、getGridParam 等来遍历网格,但是,在调试时,我注意到对于每个网格,行 ID 只是从 1 开始的数字,似乎无法区分它们。这会产生任何冲突吗?如果没有,有人可以向我解释为什么吗?我只是希望在它上线后限制任何惊喜。提前致谢!

4

3 回答 3

1

You can use idPrefix option of jqGrid to solve the problem. For example if you have two grids of the page you can use idPrefix: "g1_" for the first grid and idPrefix: "g2_" for the second one. If both grids have ids 1, 2, 3, ... in case of usage without idPrefix option then the ids of the grid with idPrefix: "g1_" will be "g1_1", "g1_2", "g1_3", ... and the ids of the grid with idPrefix: "g2_" will be "g2_1", "g2_2", "g2_3", ... In the way you will have no more id duplicates.

The option idPrefix is especially practical if you download the data from server. The option idPrefix changes local ids only. If one for example modify the row the prefix will be cut from the id value which will be sent to the server. In the way one can just work on the server with native ids from database tables.

于 2013-03-25T15:02:20.073 回答
0

行 ID 应基于您从服务器返回的数据。请参阅此处的文档部分:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data

基本上,您有责任确保返回的 XML 使用唯一id值。

于 2013-03-25T14:59:28.830 回答
0

我不知道您正在使用的网格,但我知道id应该是站点 DOM 结构内的唯一标识符。

如果网格使用该 id 进行任何类型的操作,它可能会失败。如果没有,即使 HTML 无法验证,它也可能运行良好。

于 2013-03-25T14:48:07.070 回答