jQgrid Json 格式帮助请求
我无法将 json 数据导入 jQgrid。我得到一个空网格。我希望有人有解决方案。
json 数据似乎格式不正确。
它看起来像这样:
{
"total": "3",
"page": "1",
"records": "71",
"rows": {
"1": {
"id": "1",
"cell": [
1,
" Configuration Method",
"Using traditional Weather Display"
]
},
"2": {
"id": "2",
"cell": [
2,
"CSSprint",
"weather-print-php.css"
]
},
"3": {
"id": "3",
"cell": [
3,
"CSSscreen",
"weather-screen-black-narrow.css"
]
}
}
}
问题在于“rows”之后的 {"1": 和每个新的 {"id":
之前的 "n"
它应该是 "rows":[ {"id"}
如果我手动编写 Json 代码,它就可以工作。
相关的 php 是:
if($page > 1)
{
$i = $page*30;
}
else
$i = 1;
$rows = array();
$responce['total'] = "$total_pages";
$responce['page'] = "$page";
$responce['records'] = "$count";
foreach ($this->wdConfig as $key=>$value)
{
$responce['rows'][$i]['id'] = "$i";
$responce['rows'][$i] ['cell'] = array($i,$key,$value);
$i++;
}
$this-wdConfig 是一个对象,其中包含键/值配置对。
json 输出可以在以下位置查看:
http://billhogsett.com/wd/wd2/configToJson.php
我看到了几种可能的方法,但无法弄清楚。
让 jSon 正确格式化(即 jQgrid 期望的)
配置 jSonReader 来处理我的 jSon
我会尝试并报告给我的任何建议。
谢谢。
账单
I cannot import my json data into a jQgrid. I get an empty grid. I hope someone has a solution.
The json data seems to be improperly formated.
It looks like this:
{
"total": "3",
"page": "1",
"records": "71",
"rows": {
"1": {
"id": "1",
"cell": [
1,
" Configuration Method",
"Using traditional Weather Display"
]
},
"2": {
"id": "2",
"cell": [
2,
"CSSprint",
"weather-print-php.css"
]
},
"3": {
"id": "3",
"cell": [
3,
"CSSscreen",
"weather-screen-black-narrow.css"
]
}
}
}
The problem is with the {"1" after "rows": and the "n" before each new {"id":
It should be "rows":[{"id"}
If I hand code the JSon it works.
The relevant php is:
if($page > 1)
{
$i = $page*30;
}
else
$i = 1;
$rows = array();
$responce['total'] = "$total_pages";
$responce['page'] = "$page";
$responce['records'] = "$count";
foreach ($this->wdConfig as $key=>$value)
{
$responce['rows'][$i]['id'] = "$i";
$responce['rows'][$i] ['cell'] = array($i,$key,$value);
$i++;
}
$this-wdConfig is an object that has key/value configuration pairs in it.
The jSon output can be seen at:
http://billhogsett.com/wd/wd2/configToJson.php
I see a couple of possible approaches, but cannot figure either out.
Get the jSon to format properly (i.e, what jQgrid expects)
Configure jSonReader to handle my jSon
I will try and report back on any suggestions given to me.
Thanks.
Bill
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己不使用 PHP,但也许你应该包含该行
而不是该行
I don't use PHP myself, but probably you should include the line
instead of the line