| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>TreeGrid Model-based test</title> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> |
| 6 | <style type="text/css"> |
| 7 | @import "../../../../dojo/resources/dojo.css"; |
| 8 | @import "../../../../dijit/themes/claro/claro.css"; |
| 9 | @import "../../../../dojox/grid/resources/Grid.css"; |
| 10 | @import "../../../../dojox/grid/resources/claroGrid.css"; |
| 11 | .grid { |
| 12 | width: 70em; |
| 13 | height: 40em; |
| 14 | } |
| 15 | </style> |
| 16 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, has: {'dojo-bidi': true}, mblAlwaysHideAddressBar: true"></script> |
| 17 | |
| 18 | <script type="text/javascript"> |
| 19 | require([ |
| 20 | "dojo/ready", |
| 21 | "doh/runner", |
| 22 | "dojo/dom", |
| 23 | "dojo/query", |
| 24 | "dojo/_base/lang", |
| 25 | "dojo/data/ItemFileWriteStore", |
| 26 | "dijit/tree/ForestStoreModel", |
| 27 | "dojox/grid/TreeGrid", |
| 28 | "dojo/parser", |
| 29 | "dojox/grid/cells/dijit" |
| 30 | ], function(ready, runner, dom, query, lang, ItemFileWriteStore, ForestStoreModel, TreeGrid){ |
| 31 | ready(function(){ |
| 32 | var dataItems = { |
| 33 | identifier: 'id', |
| 34 | label: 'name', |
| 35 | items: [ |
| 36 | { id: 'AF', name:'Africa!', type:'continent', population:'900 million!', area: '30,221,532 sq km', |
| 37 | timezone: '-1 UTC to +4 UTC', |
| 38 | children:[{_reference:'EG'}, {_reference:'KE'}] }, |
| 39 | { id: 'EG', name:'Egypt!', type:'country' }, |
| 40 | { id: 'KE', name:'Kenya!', type:'country', |
| 41 | children:[{_reference:'Nairobi'}, {_reference:'Mombasa'}] }, |
| 42 | { id: 'Nairobi', name:'Nairobi!', type:'city' }, |
| 43 | { id: 'Mombasa', name:'Mombasa!', type:'city' } |
| 44 | ]}; |
| 45 | var dataItems1 = lang.clone(dataItems); |
| 46 | |
| 47 | var layout = [ |
| 48 | { name: "Name!", field: "name", width: "auto" }, |
| 49 | { name: "Population!", field: "population", width: "auto" }, |
| 50 | { name: "Timezone!", field: "timezone", width: "auto" } |
| 51 | ]; |
| 52 | var jsonStore = new ItemFileWriteStore({ data: dataItems1 }); |
| 53 | var treeModel = new ForestStoreModel({ |
| 54 | store: jsonStore, |
| 55 | query: { type: 'continent' }, |
| 56 | rootId: 'continentRoot', |
| 57 | rootLabel: 'Continents', |
| 58 | childrenAttrs: ['children'] |
| 59 | }); |
| 60 | var grid2 = new TreeGrid({ |
| 61 | treeModel: treeModel, |
| 62 | structure: layout, |
| 63 | defaultOpen: true, |
| 64 | textDir: "rtl" |
| 65 | }, 'programmatic_grid'); |
| 66 | grid2.startup(); |
| 67 | dojo.connect(window, "onresize", grid2, "resize"); |
| 68 | |
| 69 | runner.register("grid.tests.bidi.test_Tree", [ |
| 70 | { |
| 71 | name: "Tree Grid , Bidi", |
| 72 | runTest: function(){ |
| 73 | query("th.dojoxGridCell").forEach(function(node, index, arr){ |
| 74 | runner.is("rtl", node.style.direction, "header should have 'direction' style corresponding to 'textDir'"); |
| 75 | }); |
| 76 | |
| 77 | query("td.dojoxGridCell").forEach(function(node, index, arr){ |
| 78 | if(node.lastChild && node.lastChild.nodeType === 3) { |
| 79 | runner.is(String.fromCharCode(8235), node.lastChild.nodeValue.charAt(0), "content cell should have direction corresponding to 'textDir'"); |
| 80 | } |
| 81 | }); |
| 82 | } |
| 83 | } |
| 84 | ]); |
| 85 | runner.register("log", function(){ |
| 86 | dom.byId('failures').innerHTML = runner._failureCount; |
| 87 | dom.byId('errors').innerHTML = runner._errorCount; |
| 88 | }); |
| 89 | runner.run(); |
| 90 | }); |
| 91 | }); |
| 92 | </script> |
| 93 | </head> |
| 94 | <body class="claro"> |
| 95 | <h1 class="testSubtitle">Bidi TreeGrid Programmatic</h1> |
| 96 | <div id="programmatic_grid"></div> |
| 97 | <br> |
| 98 | <br>Errors: <span id="errors">?</span> |
| 99 | <br>Failures: <span id="failures">?</span> |
| 100 | </body> |
| 101 | </html> |