1
此代碼有什麼問題?我可以得到我的json並用警報進行調試(以便部分可以與xhr一起使用)...例如,如果我在函數(xhr),alert(data [0] .name)中執行此操作,我會得到正確的值。網上沒有太多的例子...但指定列和添加對象存儲沒有顯示任何東西...基本上,我只是想加載一些json文件(本地)並將其呈現在網格上,但我最終將使用REST處理我的應用程序中的CRUD(因此,我將在不久的將來使用JsonRest)。Dojo OnDemandGrid(dgrid)與ObjectStore(本地json)
我認爲它也必須與AJAX ...我應該把同步到真正的(因爲它似乎我的全局變量doesn,噸工作正常...未定義)。
define([
"dojo/_base/declare",
"dijit/_WidgetBase",
"dgrid/OnDemandGrid",
"dojo/_base/xhr",
"dojo/store/Memory",
"dojo/data/ObjectStore",
"dgrid/Keyboard",
"dgrid/Selection"
], function(
declare,
_WidgetBase,
Grid,
xhr,
Memory,
ObjectStore,
Keyboard,
Selection
){
var dataStore;
xhr.get({
url: "app/resources/data/content.json",
handleAs: "json"
}).then(function(data){
dataStore = new ObjectStore({ objectStore:new Memory({ data: data.items }) });
});
return declare([_WidgetBase, Grid, Keyboard, Selection], {
store: dataStore,
columns:{
name: { label: "name" },
autodelete: { label: "autodelete" },
groupe_id: { label: "groupe_id" },
global: { label: "global" },
date: { label: "date" },
duree: { label: "duree" },
description: { label: "description" },
fichier: { label: "fichier" },
pleinecran: { label: "pleinecran" },
repertoire: { label: "repertoire" },
taille: { label: "taille" },
expiration: { label: "expiration" },
id: { label: "id" },
catergorie: { label: "catergorie" },
brouillon: { label: "brouillon" }
},
postCreate: function() {
}
});
});