JSON 和 jqGrid.什么是“用户数据"? [英] JSON and jqGrid. What is "userdata"?

查看:23
本文介绍了JSON 和 jqGrid.什么是“用户数据"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm having trouble understanding what all of the fields in a JSON datasource for a jqGrid means and I am not seeing any documentation for it anywhere.

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

The example I'm trying to understand is this: http://www.trirand.com/blog/jqgrid/jqgrid.html and then the first example under "JSON Data"

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

The JSON data can be accessed here: http://www.trirand.com/blog/jqgrid/server.php?q=2&rows=10&page=2

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

One of the things that confuse me in the JSON is this snipplet:

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

这到底是做什么的?

推荐答案

很容易解释.服务器生成将用于填充网格的数据.数据可以分页.所以在发送到服务器的 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 行)

It is very easy to explain. The server produce a data which will be used to fill the grid. The data can be paged. So in the URL send to the server we can find rows=10&page=2, which means "give me the second page of data, when the page size is 10 rows". These additional parameters will be added to the main url "server.php?q=2" defined as one of jqGrid parameters. The server give back 10 or less rows. In case of http://www.trirand.com/blog/jqgrid/server.php?q=2&rows=10&page=2 url the server gives back only 3 last rows (from the total 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 阅读器,它从发送的数据的根目录读取 data userdata 属性并保存它.该数据可访问

Now about your main question: what is "userdata"? There exists an old way to send an additional information from the server to the client together with the main data. It can be absolutely free data. All data received from server will be parsed by jqGrid with respect of so named jsonReader (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data#json_data). A standard JSON reader is defined so, that it read data userdata property from the root of data sent and just save it. This data is accessible with respect of

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"例子中使用.

Starting with the version 3.5 of jqGrid it is possible to place an additional last row in the jqGrid which could play "Summary Footer Row" role (see on http://www.trirand.com/blog/jqgrid/jqgrid.html under "New in version 3.5", "Summary Footer Row" example). Now you can see, the url in the example is absolutely the same: "server.php?q=2". So in the first example userdata will not be used, but it will be used in "Summary Footer Row" example.

这篇关于JSON 和 jqGrid.什么是“用户数据"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆