Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Nested List - example</title>
<link rel="stylesheet" href="sencha-touch.css" />
<script src="sencha-touch.js"></script>
<script>
Ext.regModel('Cars', {
fields: [
{name: 'text', type: 'string'}
]
});
var data =
{
"text": "Cars",
"items": [{
"text": "Asia",
"items": [{
"text": "Japan",
"items": [{
"text": "Acura",
"leaf": true
},{
"text": "Honda",
"leaf": true
},{
"text": "Infiniti",
"leaf": true
},{
"text": "Mitsubishi",
"leaf": true
},{
"text": "Nissan",
"leaf": true
},{
"text": "Scion",
"leaf": true
},{
"text": "Subaru",
"leaf": true
},{
"text": "Toyota",
"leaf": true
}]
},{
"text": "Korea",
"items": [{
"text": "Hyundai",
"leaf": true
},{
"text": "Kia",
"leaf": true
}]
}]
},{
"text": "United Kingdom",
"items": [{
"text": "Aston Martin",
"leaf": true
},{
"text": "Bentley",
"leaf": true
},{
"text": "TVR",
"leaf": true
},{
"text": "Land Rover",
"leaf": true
}]
},{
"text": "Europe",
"items": [{
"text": "Germany",
"items": [{
"text": "Audi",
"leaf": true
},{
"text": "BMW",
"leaf": true
},{
"text": "Opel",
"leaf": true
},{
"text": "Porsche",
"leaf": true
},{
"text": "Volkswagen",
"leaf": true
}]
},{
"text": "France",
"items": [{
"text": "Citroën",
"leaf": true
},{
"text": "Renault",
"leaf": true
},{
"text": "Peugeot",
"leaf": true
}]
}]
},{
"text": "United States",
"items": [{
"text": "Buick",
"leaf": true
},{
"text": "Cadillac",
"leaf": true
},{
"text": "Chevrolet",
"leaf": true
},{
"text": "Chrysler",
"leaf": true
},{
"text": "Ford",
"leaf": true
},{
"text": "Jeep",
"leaf": true
},{
"text": "Oldsmobile",
"leaf": true
},{
"text": "Saturn",
"leaf": true
},{
"text": "Tesla",
"leaf": true
}]
}]
}
var store = new Ext.data.TreeStore({
model: 'Cars',
root: data,
proxy: {
type: 'ajax',
reader: {
type: 'tree',
root: 'items'
}
}
});
var nestedList = new Ext.NestedList({
title: 'Cars',
store: store
});
new Ext.Application({
launch: function() {
var header = new Ext.Toolbar({
dock: 'top',
title: 'Header',
});
var footer = new Ext.Toolbar({
dock: 'top',
title: 'Footer',
});
new Ext.Panel({
fullscreen: true,
items : nestedList,
dockedItems: [
{
dock: "top",
items: header
},
{
dock: "bottom",
items: footer
}
]
});
}
});
</script>
</head>
<body></body>
</html>