
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
text: 'Continents',
children: [{
text: 'Antarctica',
leaf: true
}, {
text: 'South America',
expanded: true,
children: [{
text: 'Brazil',
leaf: true
}, {
text: 'Chile',
leaf: true
}]
}, {
text: 'Asia',
expanded: true,
children: [{
text: 'India',
leaf: true
},{
text: 'China',
leaf: true
}]
}, {
text: 'Africa',
leaf: true
}]
}
});
|
1
2
3
4
5
6
7
8
|
Ext.create('Ext.tree.Panel', {
title: 'Basic Tree',
width: 200,
height: 450,
store: store,
rootVisible: true,
renderTo: Ext.getBody()
});
|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
text: 'Continents',
checked: false,
children: [{
text: 'Antarctica',
leaf: true ,
checked: false
},{
text: 'South America',
expanded: false,
checked: true,
children: [{
text: 'Chile',
leaf: true,
checked: true
}]
},{
text: 'Asia',
expanded: true,
checked: true,
children: [{
text: 'India',
leaf: true,
checked: true
},{
text: 'China',
leaf: true,
checked: true
}]
},{
text: 'Africa',
leaf: true,
checked: true
}]
}
});
Ext.create('Ext.tree.Panel', {
title: 'Basic Tree',
width: 200,
height: 450,
store: store,
rootVisible: true,
useArrows: true,
lines: false,
renderTo: Ext.getBody(),
viewConfig: {
plugins: {
ptype: 'treeviewdragdrop',
containerScroll: true
}
}
});
|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
text: 'Continents',
children: [{
name: 'Antarctica',
population: 0,
area: 14,
leaf: true
},{
name: 'South America',
population: 385 ,
area: 17.84,
expanded: false,
children: [{
name: 'Chile',
population: 18,
area: 0.7,
leaf: true,
}]
},{
name: 'Asia',
expanded: true,
population: 4164,
area: 44.57,
children: [{
name: 'India',
leaf: true,
population: 1210,
area: 3.2
},{
name: 'China',
leaf: true,
population: 1357,
area: 9.5
}]
},{
name: 'Africa',
leaf: true,
population: 1110,
area: 30
}]
}
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
Ext.create('Ext.tree.Panel', {
title: 'Tree Grid',
width: 500,
height: 450,
store: store,
rootVisible: false,
useArrows: true,
lines: false,
scope: this,
renderTo: Ext.getBody(),
columns: [{
xtype: 'treecolumn',
text: 'Name',
flex: 1,
sortable: true,
dataIndex: 'name'
} , {
text: 'Population (millons)',
sortable: true,
width: 150,
dataIndex: 'population'
} , {
text: 'Area (millons km^2)',
width: 150,
sortable: true,
dataIndex: 'area'
}]
});
|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
Ext.define('Person', {
extend : 'Ext.data.Model',
fields : [ {
name : 'name',
type : 'string'
}, {
name : 'age',
type : 'int'
}, {
name : 'gender',
type : 'int'
} ]
});
Ext.create('Ext.data.Store', {
id : 'employees',
model : 'Person',
data : [{
name : 'Mike',
age : 22,
gender : 0
},{
name : 'Woo',
age : 32,
gender : 1
},{
name : 'John',
age : 33,
gender : 1
},{
name : 'Kalai',
age : 25,
gender : 0
}]
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
var empTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="margin-bottom: 10px;" class="data-view">',
'<table style="width:100%">',
'<tr>',
'<td style="font-size: 100px;width:100px;" rowspan="3"><i class="fa fa-user"></i></td>',
'<td>Name: {name}< /td>',
'</tr>',
'<tr>',
'<td>Age:{age}< /td>',
'</tr>',
'<tr>',
'<td>Gender: <tpl if="gender == 1">',
'<i class="fa fa-mars"></i>',
'<tpl else>',
'<i class="fa fa-venus"></i>',
'</tpl></td>',
'</tr></table> ',
'</div>',
'</tpl>'
) ;
|
1
|
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font- awesome/4.3.0/css/font-awesome.min.css">
|
1
2
3
4
5
6
7
8
9
10
11
|
Ext.create('Ext.view.View', {
store : Ext.getStore('employees'),
tpl : empTpl,
itemSelector : 'div.data-view',
renderTo : Ext.getBody(),
listeners : {
itemclick : function(node, rec, item, index, e) {
alert(rec.data.name);
}
}
});
|



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
Ext.define('PE.view.pics.Pics', {
extend : 'Ext.panel.Panel',
/* Marks these are required classes to be to loaded before loading this view */
requires : [ 'PE.view.pics.PicsController' ],
xtype : 'app-pics',
controller : 'pics',
items : [ {
xtype : 'container',
layout : 'hbox',
cls : 'pics-list',
items : [ {
xtype : 'treepanel',
width : 200,
height : '100%',
store : 'albums',
border : true,
useArrows : true,
cls : 'tree',
rootVisible : false,
listeners : {
itemdblclick : 'onNodeSelect'
},
dockedItems : [ {
xtype : 'toolbar',
dock : 'top',
ui : 'footer',
items : [{
xtype : 'component',
flex : 1
},{
xtype : 'button',
text : 'Upload',
cls : 'btn-blue'
}]
}]
},{
xtype : 'dataview',
reference : 'picsList',
cls : 'pics-list-content',
store : 'pics',
tpl : [
'<tpl for=".">',
'<div class="thumb"><img src="{url}" title=""></div>',
'</tpl>'
],
multiSelect : true,
minHeight : 400,
flex : 1,
trackOver : true,
overItemCls : 'x-item-over',
itemSelector : 'div.thumb',
emptyText : 'No images to display'
}]
}]
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
Ext.define('PE.view.pics.PicsController', {
extend : 'Ext.app.ViewController',
alias : 'controller.pics',
views : [ 'PE.view.pics.Pics' ],
requires : [ 'PE.store.Pics', 'PE.store.Albums' ],
onNodeSelect : function(node, rec, item, index, e){
var albums = [];
albums.push(rec.id);
rec.childNodes.forEach(function(item) {
albums.push(item.id);
});
Ext.getStore('pics').filter({
property : 'albumId',
operator : 'in',
value : albums
});
}
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
Ext.define('Pic', {
extend : 'Ext.data.Model',
fields : [ 'id', 'url', 'albumId' ]
});
Ext.define('PE.store.Pics', {
extend : 'Ext.data.Store',
storeId : 'pics',
model : 'Pic',
proxy : {
type : 'rest',
url : 'pics', // URL that will load data with respect to start and limit params
reader : {
type : 'json'
}
}
});
Ext.create('PE.store.Pics').load();
Ext.define('PE.store.Albums', {
extend : 'Ext.data.TreeStore',
storeId : 'albums',
root : {
expanded : true,
children : [ {
id : 100,
text : ' California',
expanded : true,
children : [ {
id : 600,
text : ' Big Sur',
leaf : true
}, {
id : 500,
text : ' Yosemite',
leaf : true
}]
}, {
id : 400,
text : ' Arizona',
expanded : true,
children : [ {
id : 300,
text : ' Horseshoe bend',
leaf : true
}]
}, {
id : 200,
text : ' Home',
leaf : true
}, {
id : 700,
text : ' India',
expanded : true,
children : [ {
id : 800,
text : ' Ooty',
leaf : true
}, {
id : 900,
text : ' Chennai',
leaf : true
}, {
id : 1000,
text : ' Munnar',
leaf : true
} ]
} ]
}
});
Ext.create('PE.store.Albums');
|
1
2
3
4
5
6
|
// Configure the pics as draggable var pics = Ext.get('pics').select('div');
Ext.each(pics.elements, function(el) {
var dd = Ext.create('Ext.dd.DD', el, ' picsDDGroup', {
isTarget : false
});
});
|
1
2
3
4
5
|
var albums = Ext.get('album').select('div');
Ext.each(albums.elements, function(el) {
var albumDDTarget = Ext.create('Ext.dd.DDTarget', el,
'picsDDGroup');
});
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
var overrides = {
onDragDrop : function(evtObj, targetElId) {
var dropEl = Ext.get(targetElId);
if (this.el.dom.parentNode.id != targetElId) {
dropEl.appendChild(this.el);
this.onDragOut(evtObj, targetElId);
this.el.dom.style.position = '';
this.el.dom.style.top = '';
this.el.dom.style.left = '';
} else {
this.onInvalidDrop();
}
},
onInvalidDrop : function() {
this.invalidDrop = true;
}
};
|
1
2
3
4
5
6
7
8
|
var albums = Ext.get('album').select('div');
var pics = Ext.get('pics').select('div');
Ext.each(pics.elements, function(el) {
var dd = Ext.create('Ext.dd.DD', el, ' picsDDGroup', {
isTarget : false
});
Ext.apply(dd, overrides);
});
|