本文介绍了将编码的JSON加载到Dojo Grid中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在PHP编程,
我想要一个数组我有(从mysql结果集中提取),将其转换为 JSON 然后在 dojox.grid.DataGrid 中使用它。



我从获得了一个想法:



我在数组中使用了以下内容(在名为的文件中,getJSON.php

  echo $ ajax ={identifier:'db_id','items':json_encode ) }。 

然后我尝试这样做(在我的主页):

  var store = new dojo.data.ItemFileWriteStore({url:'getJSON.php'}); 

其他所有内容与Dojo文档指定的完全一样。
网格显示,但不加载数据,而是写入对不起,发生错误



解决方案

我不使用ItemFileWriteStore!他们改变了很多Dojo 1.6,所以也许你看一些不是最新的东西。



尝试这段代码:

请尝试这个代码,首先回应一些简单的东西:

之后用你自己的JSON ...


I am programming in php,I want to take an array I have (which is extracted from mysql result set), convert it to JSON and then use it in dojox.grid.DataGrid.

I got an idea from this link:

I used the following on the array (in a file called getJSON.php)

echo $ajax = "{identifier: 'db_id', 'items':".json_encode($array)."}";

Then I try doing this (in my main page):

var store = new dojo.data.ItemFileWriteStore({ url: 'getJSON.php' });

Everything else is exactly as the Dojo documentation specifies.The grid shows up, but doesn't load the data and instead writes Sorry, an error occurred

Does anyone know the reason? Hopefully I gave you enough to go on.

解决方案

i don't use ItemFileWriteStore for that ! They changed a lot since Dojo 1.6 , so maybe you looked at something not up to date.

Try this code:

Please try this code by echoing something simple like this first:

And after that with your own JSON...

这篇关于将编码的JSON加载到Dojo Grid中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:38