Updated
This commit is contained in:
107
master/examples/test_treegrid_model_lazy.html
Normal file
107
master/examples/test_treegrid_model_lazy.html
Normal file
@@ -0,0 +1,107 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>dojox.grid.TreeGrid Model-based lazy loading test</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
|
||||
<style type="text/css">
|
||||
@import "../../../dojo/resources/dojo.css";
|
||||
@import "../../../dijit/themes/tundra/tundra.css";
|
||||
@import "../resources/Grid.css";
|
||||
@import "../resources/tundraGrid.css";
|
||||
.grid {
|
||||
width: 70em;
|
||||
height: 40em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: false"></script>
|
||||
<script type="text/javascript">
|
||||
dojo.require("dojox.grid.TreeGrid");
|
||||
dojo.require("dijit.tree.ForestStoreModel");
|
||||
dojo.require("dojox.data.JsonRestStore");
|
||||
dojo.require("dijit.form.Button");
|
||||
dojo.require("dojo.parser");
|
||||
|
||||
|
||||
jsonStore = null, childItems = null, dataItems = null, fullItems = null;
|
||||
dojo.addOnLoad(function(){
|
||||
childItems = {
|
||||
'AF': [
|
||||
{ id: 'EG', name:'Egypt', type:'country' },
|
||||
{ id: 'KE', name:'Kenya', type:'country' },
|
||||
{ id: 'SD', name:'Sudan', type:'country' }
|
||||
],
|
||||
'KE': [
|
||||
{ id: 'Nairobi', name:'Nairobi', type:'city' },
|
||||
{ id: 'Mombasa', name:'Mombasa', type:'city' }
|
||||
],
|
||||
'SD': [
|
||||
{ id: 'Khartoum', name:'Khartoum', type:'city' }
|
||||
],
|
||||
'AS': [
|
||||
{ id: 'CN', name:'China', type:'country' },
|
||||
{ id: 'IN', name:'India', type:'country' },
|
||||
{ id: 'RU', name:'Russia', type:'country' },
|
||||
{ id: 'MN', name:'Mongolia', type:'country' }
|
||||
],
|
||||
'OC': [
|
||||
{ id: 'AU', name:'Australia', type:'country', population:'21 million'}
|
||||
],
|
||||
'EU': [
|
||||
{ id: 'DE', name:'Germany', type:'country' },
|
||||
{ id: 'FR', name:'France', type:'country' },
|
||||
{ id: 'ES', name:'Spain', type:'country' },
|
||||
{ id: 'IT', name:'Italy', type:'country' }
|
||||
]
|
||||
};
|
||||
dataItems = [
|
||||
{ id: 'AF', name:'Africa', type:'continent', population:'900 million', area: '30,221,532 sq km',
|
||||
timezone: '-1 UTC to +4 UTC', children: true, '$ref': 'AF' },
|
||||
{ id: 'AS', name:'Asia', type:'continent', children: true, '$ref': 'AS' },
|
||||
{ id: 'OC', name:'Oceania', type:'continent', population:'21 million', children: true, '$ref': 'OC' },
|
||||
{ id: 'EU', name:'Europe', type:'continent', children: true, '$ref': 'EU' }
|
||||
];
|
||||
fullItems = {};
|
||||
dojo.forEach(dataItems, function(item){
|
||||
var full = fullItems[item.id] = dojo.mixin({}, item, { children: childItems[item.id] });
|
||||
delete full['$ref'];
|
||||
});
|
||||
var mockService = function(query){
|
||||
var d = new dojo.Deferred();
|
||||
if(typeof query == 'string'){
|
||||
setTimeout(function(){
|
||||
d.callback(fullItems[query]);
|
||||
}, 500);
|
||||
}else{
|
||||
d.fullLength = dataItems.length;
|
||||
d.callback(dataItems);
|
||||
}
|
||||
return d;
|
||||
};
|
||||
jsonStore = new dojox.data.JsonRestStore({
|
||||
service: mockService,
|
||||
target: '/some/url'
|
||||
});
|
||||
dojo.parser.parse();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body class="tundra">
|
||||
<h1 class="testTitle">Test: dojox.grid.TreeGrid - Model-based lazy loading</h1>
|
||||
|
||||
<div dojoType="dijit.tree.ForestStoreModel" jsId="continentModel"
|
||||
store="jsonStore" query="{type:'continent'}"
|
||||
deferItemLoadingUntilExpand="true"
|
||||
rootId="continentRoot" rootLabel="Continents" childrenAttrs="children">
|
||||
</div>
|
||||
|
||||
<h4 class="testSubtitle">dojox.grid.TreeGrid n-Level</h4>
|
||||
<table jsid="grid" dojoType="dojox.grid.TreeGrid" class="grid" treeModel="continentModel">
|
||||
<thead>
|
||||
<tr>
|
||||
<th field="name" width="auto">Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user