0

I want to save some unneeded requests and time for displaying a table the first time and so I thought maybe I could set the initial data directly without any ajax-request. I tried it like that:

$('#testTable').flexAddData('[formatted json here]');

and also that

$('#testTable').addData('[formatted json here]');

But it hasn't any effect. Can I do that and what is the right syntax?

4

3 回答 3

2

我也遇到了这个问题,并花了很多时间试图解决它。就我而言,解决方案非常简单。您只需要在flexigrid()函数中明显指定 dataType : "json" 。默认数据类型为 XML。所以,它不想理解 JSON:

$("#myTable").flexigrid({dataType : "json"});
于 2012-10-08T12:24:36.470 回答
1

你用过eval()吗?

$("#testTable").flexAddData(eval('[formatted json here]'));

或尝试

$("#testTable").flexAddData(eval('[formatted json here]')).flexReload();

希望这可以帮助

于 2012-01-19T06:17:30.490 回答
0

为了补充Anwaruser1635430的答案,这里是一个示例 JSON 代码:

{
"page": "1",
"total": "9",
"rows": [
    {
        "id": "1",
        "cell": [
            "1",
            "text1",
            "user1",
            "date1"
        ]
    }
 ]
}

代码由Anwar完成,我从他对其他问题的回答中“偷”了它。

于 2014-06-23T19:12:15.487 回答