'children'속성을 포함하는 항목이있는 dojo.data.ItemFileWriteStore 객체가 있습니다. 그러면 children 항목의 배열이 차례로 포함됩니다. 나는 나무를 저장하고 있는데,이 나무에서 잎 노드를 가져와야합니다. fetch 메소드를 작성했지만 "children : []"쿼리를 사용하면 작동하지 않습니다 children.length가 0 (리프 노드) 인 데이터 저장소 항목을 가져올 수 있습니까? 'leaf'와 같은 속성을 추가하지 않은 빈 배열 : 내 항목에 bool이 적용되지만 분명히 추가 속성을 갖고 싶지는 않습니다. dojo.data.ItemFileWriteStore에 대한 속성 등록 정보 쿼리 (매우 쉽지 않음)
dojo.require(dojo.data.ItemFileWriteStore);
// A tree node with no children, these are the kind I want returned
// from the query!
var rootItem = {
children: []
};
var treeStore = new dojo.data.ItemFileWriteStore({
data: {
items: [rootItem]
}
});
//when dojo reaches one of its inner filtering methods
//there is a point where it calls dojo.some() to see
//which elements in the array to return which match the
//given items attribute, this is where it fails
treeStore.fetch({
query: {children: []},
queryOptions: {deep: true},
onComplete: function(leafItems) {
// All the items with no children here...
}
});
는 또한 아무 소용이 속성에 대한 기능을 중첩 시도 :
treeStore.fetch({
query: {
children: function(store, item){
return store.getValue(item, 'children').length == 0;
}
},
queryOptions: {deep: true},
onComplete: function(leafItems) {
// All the items with no children here...
}
});
데이터 저장소의 계층 적 데이터가 너무 크지는 않지만, 아마도 Dojo 데이터 저장소는 계층 적 데이터를 지원합니다. 계층 옵션 등을 켜야합니다. Google과 함께하면 찾을 수 있습니다. –