Skip to content

Commit 87e4732

Browse files
committed
added tree panel and tree store
1 parent ed2096e commit 87e4732

1 file changed

Lines changed: 45 additions & 5 deletions

File tree

demo/demo.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ Ext.onReady(function () {
2828
storeId: 'myStore'
2929
});
3030

31-
//store.proxy.store = store;
32-
3331
var grid = Ext.create('Ext.grid.Panel', {
3432
renderTo: Ext.getBody(),
3533
title: 'WebSocketed Grid',
@@ -77,9 +75,7 @@ Ext.onReady(function () {
7775
text: 'Read',
7876
icon: 'images/arrow-circle.png',
7977
handler: function (btn) {
80-
store.load(function (records, operation, success) {
81-
// console.log (records);
82-
});
78+
store.load();
8379
}
8480
} , '-' , {
8581
text: 'Update',
@@ -126,4 +122,48 @@ Ext.onReady(function () {
126122
yField: 'age'
127123
}]
128124
});
125+
126+
Ext.define('TreeModel', {
127+
extend: 'Ext.data.Model',
128+
fields: [{
129+
name: 'text',
130+
mapping: 'name',
131+
type: 'string'
132+
} , {
133+
name: 'leaf',
134+
type: 'boolean'
135+
}]
136+
});
137+
138+
var treeStore = Ext.create('Ext.data.TreeStore', {
139+
storeId: 'myTreeStore',
140+
autoLoad: true,
141+
model: 'TreeModel',
142+
proxy: {
143+
type: 'websocket',
144+
url: 'ws://localhost:9001',
145+
storeId: 'myTreeStore',
146+
api: {
147+
create: 'user/create',
148+
read: 'user/read',
149+
update: 'user/update',
150+
destroy: 'user/destroy'
151+
},
152+
reader: {
153+
type: 'json',
154+
root: 'children'
155+
}
156+
},
157+
root: {
158+
expanded: true
159+
}
160+
});
161+
162+
var tree = Ext.create('Ext.tree.Panel', {
163+
renderTo: Ext.getBody(),
164+
title: 'WebSocketed Tree Panel',
165+
width: 500,
166+
height: 300,
167+
store: treeStore
168+
});
129169
});

0 commit comments

Comments
 (0)