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?
Did you use the eval()
?
$("#testTable").flexAddData(eval('[formatted json here]'));
or try
$("#testTable").flexAddData(eval('[formatted json here]')).flexReload();
hope this helps
I've also met this problem and spent a lot of time trying to solve it. Solution in my case was pretty simple. You just need to specify dataType : "json" obviously in flexigrid()
function. Default dataType is XML. So, it don't want to understand JSON:
$("#myTable").flexigrid({dataType : "json"});
To supplement Anwar and user1635430 answers, here is an example JSON code:
{
"page": "1",
"total": "9",
"rows": [
{
"id": "1",
"cell": [
"1",
"text1",
"user1",
"date1"
]
}
]
}
The code is done by Anwar, I "stole" it from his answer on some other question.