프로그래밍 방식으로 이미 초기화 된 TreeStore에 데이터를 추가하는 방법을 이해하는 데 어려움을 겪고 있습니다. 난 단지 4 부모 항목이 추가 얻을 결과Sencha Touch 2.4 : 프로그래밍 방식으로 TreeStore에 여러 레코드를 추가하는 방법
var data = {
"items" : [{
"text" : "Today",
"items" : [{
"text" : "Eat",
"leaf" : true
}, {
"text" : "Sleep",
"leaf" : true
}, {
"text" : "Drinking",
"leaf" : true
}]
}, {
"text" : "Tomorrow",
"items" : [{
"text" : "Watch TV",
"leaf" : true
}, {
"text" : "Watch Video",
"leaf" : true
}]
}, {
"text" : "This week",
"items" : [{
"text" : "Shopping",
"leaf" : true
}]
}, {
"text" : "Later",
"items" : [{
"text" : "Eat",
"leaf" : true
}, {
"text" : "Sleep",
"leaf" : true
}, {
"text" : "Drinking",
"leaf" : true
}]
}]
};
Ext.define('Task', {
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'text',
type: 'string'
}]
}
});
var store = Ext.create('Ext.data.TreeStore', {
model: 'Task',
defaultRootProperty: 'items',
//root: data
});
store.addData(data.items); // I need to add data here
console.log(store.getAllCount()) // prints 4 but should be 13
:
는 센차 터치 문서의 예를 생각해 보자. 아이가 추가되지 않습니다.미리 감사드립니다.
대신 당신이 defaultRootProperty을 알 더주의 깊게 내 코드를 살펴있는 경우' –