3

我无法理解 jqGrid 的 JSON 数据源中的所有字段的含义,而且我在任何地方都没有看到任何文档。

我试图理解的例子是:http ://www.trirand.com/blog/jqgrid/jqgrid.html然后是“JSON 数据”下的第一个例子

JSON数据可以在这里访问:http ://www.trirand.com/blog/jqgrid/server.php?q=2&rows=10&page=2

在 JSON 中让我感到困惑的一件事是这个片段:

"userdata":{"amount":1520,"tax":202,"total":1724,"name":"Totals:"}

这究竟是在做什么?

4

2 回答 2

7

这很容易解释。服务器生成将用于填充网格的数据。数据可以分页。所以在发送到服务器的 URL 中我们可以找到rows=10&page=2,意思是“给我第二页数据,当页面大小为 10 行时”。这些附加参数将添加到定义为 jqGrid 参数之一的主 url “server.php?q=2”。服务器返回 10 行或更少的行。如果是http://www.trirand.com/blog/jqgrid/server.php?q=2&rows=10&page=2 url,服务器只返回最后 3 行(总共 10 行)

{"page":"2",
 "total":2,
 "records":"13",
 "rows":[
   {"id":"11","cell":["11","2007-10-06","Client 1","600.00","120.00","720.00",null]},
   {"id":"12","cell":["12","2007-10-06","Client 2","700.00","140.00","840.00",null]},
   {"id":"13","cell":["13","2007-10-06","Client 3","1000.00","0.00","1000.00",null]}
 ],
 "userdata":{"amount":2300,"tax":260,"total":2560,"name":"Totals:"}
}

现在关于您的主要问题:什么是“用户数据”?有一种旧方法可以将附加信息与主要数据一起从服务器发送到客户端。它可以是完全免费的数据。从服务器接收到的所有数据都将由 jqGrid 解析,以命名jsonReader(参见http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data)。定义了一个标准的 JSON 读取器,它userdata从发送的数据的根读取数据属性并保存它。该数据可在以下方面访问

var myUserData = jQuery("grid_id").getGridParam('userData');

(见http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#user_data)。

从 jqGrid 3.5 版开始,可以在 jqGrid 中放置一个额外的最后一行,它可以扮演“摘要页脚行”角色(参见http://www.trirand.com/blog/jqgrid/jqgrid.html下的“ 3.5 版中的新功能”,“摘要页脚行”示例)。现在可以看到,示例中的url是完全一样的:“server.php?q=2”。所以在第一个示例userdata中不会使用,但会在“Summary Footer Row”示例中使用。

于 2010-06-27T21:20:04.677 回答
1

That seems to be the sum of the columns 'Amount' 'Tax' and 'Total' on the second paginated page assuming that the grid is ordered by the 'Inv No' low to high.

These values do not appear to be being used by that particular grid, but perhaps they are used in one of the other live examples which is why they are there.

于 2010-06-27T21:18:38.673 回答