jQgrid Json 格式帮助请求

发布于 2024-10-20 08:15:00 字数 1718 浏览 3 评论 0原文

我无法将 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

我看到了几种可能的方法,但无法弄清楚。

  1. 让 jSon 正确格式化(即 jQgrid 期望的)

  2. 配置 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.

  1. Get the jSon to format properly (i.e, what jQgrid expects)

  2. Configure jSonReader to handle my jSon

I will try and report back on any suggestions given to me.

Thanks.

Bill

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

双马尾 2024-10-27 08:15:00

我自己不使用 PHP,但也许你应该包含该行

$responce['rows'] = array();

而不是该行

$rows = array();

I don't use PHP myself, but probably you should include the line

$responce['rows'] = array();

instead of the line

$rows = array();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文