| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>dojox.grid.TreeGrid Lazy-loading for children items test</title> |
| 6 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 7 | <style type="text/css"> |
| 8 | @import "../../../../dojo/resources/dojo.css"; |
| 9 | @import "../../../../dijit/themes/claro/claro.css"; |
| 10 | @import "../../../../dojox/grid/resources/Grid.css"; |
| 11 | @import "../../../../dojox/grid/resources/tundraGrid.css"; |
| 12 | @import "../../../../dojox/grid/resources/claroGrid.css"; |
| 13 | body { |
| 14 | font-size: 0.9em; |
| 15 | font-family: Geneva, Arial, Helvetica, sans-serif; |
| 16 | padding: 0.5em; |
| 17 | } |
| 18 | .title { |
| 19 | text-align:center; |
| 20 | margin:1em; |
| 21 | } |
| 22 | #grid1 { |
| 23 | width: 50em; |
| 24 | height: 15em; |
| 25 | border: 1px solid #333333; |
| 26 | } |
| 27 | </style> |
| 28 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, has: {'dojo-bidi': true}, mblAlwaysHideAddressBar: true"></script> |
| 29 | <script type="text/javascript"> |
| 30 | require([ |
| 31 | "dojo/ready", |
| 32 | "doh/runner", |
| 33 | "dojo/dom", |
| 34 | "dojo/query", |
| 35 | "dojo/_base/lang", |
| 36 | "dojo/data/ItemFileReadStore", |
| 37 | "dojox/grid/LazyTreeGridStoreModel", |
| 38 | "dojo/parser", |
| 39 | "dojox/grid/cells/dijit", |
| 40 | "dijit/form/ComboBox" |
| 41 | ], function(ready, runner, dom, query, lang, ItemFileReadStore, LazyTreeGridStoreModel){ |
| 42 | var continentItems = [ |
| 43 | {name:'South America!', type:'continent', population:''}, |
| 44 | {name:'North America!', type:'continent', population:''}, |
| 45 | {name:'Asia!', type:'continent', population:''}, |
| 46 | {name:'Oceania!', type:'continent', population:''}, |
| 47 | {name:'Europe!', type:'continent', population:''} |
| 48 | ]; |
| 49 | var continentChildrenList = []; |
| 50 | for(var i=0; i < continentItems.length; i++){ |
| 51 | continentChildrenList.push(lang.mixin({ id: 'continent_' + i }, continentItems[i])); |
| 52 | } |
| 53 | |
| 54 | var countryItems = [ |
| 55 | {name:'Egypt!', type:'country', population:''}, |
| 56 | {name: 'Kenya!', type: 'country', population:''}, |
| 57 | {name:'Sudan!', type:'country', population:''}, |
| 58 | {name:'China!', type:'country' , population:''}, |
| 59 | {name:'India!', type:'country' , population:''} |
| 60 | ]; |
| 61 | |
| 62 | var countryChildrenList = []; |
| 63 | for(var i=0; i < countryItems.length; i++){ |
| 64 | countryChildrenList.push(lang.mixin({ id: 'country_' + i }, countryItems[i])); |
| 65 | } |
| 66 | |
| 67 | cityItems = [ |
| 68 | {name:'Nairobi!', type:'city', population:''}, |
| 69 | {name:'Mombasa!', type:'city', population:''}, |
| 70 | {name:'Khartoum!', type:'city', population:''}, |
| 71 | {name:'Mexico City!', type:'city', population:'19 million.'}, |
| 72 | {name:'Guadalajara!', type:'city', population:'4 million.'} |
| 73 | ]; |
| 74 | |
| 75 | var cityChildrenList = []; |
| 76 | for(var i=0; i < cityItems.length; i++){ |
| 77 | cityChildrenList.push(lang.mixin({ id: 'city_' + i }, cityItems[i])); |
| 78 | } |
| 79 | |
| 80 | var dataItems = { |
| 81 | identifier: 'id', |
| 82 | label: 'name', |
| 83 | items: [ |
| 84 | {id:'Continent', name:'Continent!', type:'', population: '', children: continentChildrenList}, |
| 85 | {id:"Country", name:"Country!", type:"", population: '', children: countryChildrenList}, |
| 86 | {id:"City", name:"City!", type:"", population: '', children: cityChildrenList} |
| 87 | ] |
| 88 | }; |
| 89 | |
| 90 | var readStore = new ItemFileReadStore({data: dataItems}); |
| 91 | model1 = new LazyTreeGridStoreModel({store: readStore, childrenAttrs: ['children']}) |
| 92 | layout = [ |
| 93 | {name: 'Name!', field: 'name', width: 'auto'}, |
| 94 | {name: 'Type!', field: 'type', width: 'auto'}, |
| 95 | {name: 'Population!', field: 'population', width: 'auto'} |
| 96 | ] |
| 97 | |
| 98 | ready(function(){ |
| 99 | runner.register("grid.tests.bidi.test_LazyLoadTree", [ |
| 100 | { |
| 101 | name: "Lazyload Tree Grid , Bidi", |
| 102 | runTest: function(){ |
| 103 | query("th.dojoxGridCell").forEach(function(node, index, arr){ |
| 104 | runner.is("rtl", node.style.direction, "header should have 'direction' style corresponding to 'textDir'"); |
| 105 | }); |
| 106 | |
| 107 | query("td.dojoxGridCell").forEach(function(node, index, arr){ |
| 108 | if(node.lastChild && node.lastChild.tagName && |
| 109 | node.lastChild.tagName.toUpperCase() === "DIV" && node.lastChild.lastChild |
| 110 | && node.lastChild.lastChild.nodeType === 3 && node.lastChild.lastChild.nodeValue) { |
| 111 | runner.is(String.fromCharCode(8235), node.lastChild.lastChild.nodeValue.charAt(0), "content cell should have direction corresponding to 'textDir'"); |
| 112 | } |
| 113 | }); |
| 114 | } |
| 115 | } |
| 116 | ]); |
| 117 | runner.register("log", function(){ |
| 118 | dom.byId('failures').innerHTML = runner._failureCount; |
| 119 | dom.byId('errors').innerHTML = runner._errorCount; |
| 120 | }); |
| 121 | runner.run(); |
| 122 | }); |
| 123 | }); |
| 124 | </script> |
| 125 | </head> |
| 126 | <body class="claro"> |
| 127 | <h1 class="title">Bidi TreeGrid - Lazy-loading</h1> |
| 128 | <div id='grid1' data-dojo-id='grid1' data-dojo-type='dojox/grid/LazyTreeGrid' |
| 129 | data-dojo-props='textDir: "rtl", structure:layout, treeModel:model1, rowSelector:"true" '></div> |
| 130 | |
| 131 | <br>Errors: <span id="errors">?</span> |
| 132 | <br>Failures: <span id="failures">?</span> |
| 133 | </body> |
| 134 | </html> |