이 코드의 문제점은 무엇입니까? 나는 내 json을 얻을 수 있고 경고 (예 : xhr과 함께 작동합니다)를 디버깅 할 수 있습니다 ... 예를 들어,이 함수 내에서 (xhr), alert (data [0] .name) 값. Web에는 그다지 많은 예제가 없습니다 ...하지만 열을 지정하고 객체 저장소를 추가해도 아무 것도 표시되지 않습니다 ... 기본적으로 json 파일 (로컬)을로드하고 그리드에 렌더링하려고하지만 결국 내 응용 프로그램 내에서 CRUD를 처리하기 위해 REST를 사용할 것입니다 (그래서 JsonRest를 조만간 사용하게 될 것입니다).ObjectStore (로컬 json)가있는 Dojo OnDemandGrid (dgrid)
나는 AJAX 와도 관련이 있다고 생각한다. 아마도 나는 sync를 true로 설정해야한다. (내 전역 변수는 보이지 않기 때문에 ... 제대로 정의되지 않았다.)
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() {
}
});
});