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

查看:81
本文介绍了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数据:

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读取器,以便它从发送的数据的根读取数据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中放置一个附加的最后一行,该行可以扮演摘要页脚行"角色(请参见userdata,但在摘要页脚行"示例中将使用它.

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天全站免登陆