| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 2 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 | <title>Grid Edit Controls Bidi Test</title> |
| 7 | <style type="text/css"> |
| 8 | @import "../../resources/Grid.css"; |
| 9 | @import "../../resources/tundraGrid.css"; |
| 10 | @import "../../../../dojo/resources/dojo.css"; |
| 11 | @import "../../../../dijit/themes/tundra/tundra.css"; |
| 12 | @import "../../../../dijit/themes/tundra/tundra_rtl.css"; |
| 13 | @import "../../../../dijit/tests/css/dijitTests.css"; |
| 14 | #controls button { |
| 15 | margin-left: 10px; |
| 16 | } |
| 17 | #grid { |
| 18 | width: 450px; |
| 19 | height: 150px; |
| 20 | border: 1px solid silver; |
| 21 | } |
| 22 | </style> |
| 23 | |
| 24 | <script type="text/javascript" src="../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true, mblAlwaysHideAddressBar: true, has: {'dojo-bidi': true}"></script> |
| 25 | |
| 26 | <script type="text/javascript"> |
| 27 | require([ |
| 28 | "dojo/ready", |
| 29 | "dijit/registry", |
| 30 | "doh/runner", |
| 31 | "dojo/dom", |
| 32 | "dojo/query", |
| 33 | "dojo/data/ItemFileWriteStore", |
| 34 | "dojo/parser", |
| 35 | "dojox/grid/cells/dijit", |
| 36 | "dijit/form/ComboBox" |
| 37 | ], function(ready, registry, runner, dom, query, ItemFileWriteStore){ |
| 38 | data = {identifier: 'id',label: 'id',items: []}; |
| 39 | data_list = [ |
| 40 | { col1: "First!", col2: "First!", col3: "First!", col4: "First!"}, |
| 41 | { col1: "Second!", col2: "Second!", col3: "Second!", col4: "Second!"}, |
| 42 | { col1: "Third!", col2: "Third!", col3: "Third!", col4: "Third!"}, |
| 43 | { col1: "Forth!", col2: "Forth!", col3: "Forth!", col4: "Forth!"} |
| 44 | ]; |
| 45 | for(var i=0; i < 4; i++){ |
| 46 | data.items.push(dojo.mixin({ id: i }, data_list[i])); |
| 47 | } |
| 48 | test_store = new ItemFileWriteStore({data: data}); |
| 49 | gridLayout = [{ |
| 50 | defaultCell: { width: 8, editable: true, alwaysEditing: true, type: dojox.grid.cells._Widget, styles: 'text-align: right;' }, |
| 51 | rows: [ |
| 52 | { name: 'Input!', field: 'col1'}, |
| 53 | { name: 'grid.cells.ComboBox!', styles: 'text-align: center;', field: 'col2', |
| 54 | type: dojox.grid.cells.ComboBox, |
| 55 | options: ["First!", "Second!", "Third!", "Forth!"], width: 10}, |
| 56 | { name: 'grid.cells.Select!', field: 'col3', styles: 'text-align: center;', |
| 57 | type: dojox.grid.cells.Select, options: [ "First!", "Second!", "Third!", "Forth!"]}, |
| 58 | { name: 'dijit.form.Combo!', field: 'col4', |
| 59 | widgetClass: dijit.form.ComboBox, width: 10} |
| 60 | ] |
| 61 | }]; |
| 62 | |
| 63 | ready(function(){ |
| 64 | runner.register("grid.tests.bidi.test_EditControls", [ |
| 65 | { |
| 66 | name: "Grid EditControls, Bidi", |
| 67 | runTest: function(){ |
| 68 | query("th.dojoxGridCell").forEach(function(node, index, arr){ |
| 69 | runner.is("rtl", node.style.direction, "header should have 'direction' style corresponding to 'textDir'"); |
| 70 | }); |
| 71 | var element = registry.byId('dijit_form_TextBox_0'); |
| 72 | if(element) { |
| 73 | runner.is("rtl", element.get("textDir"), "widget 'textDir' property should coinside with that of grid"); |
| 74 | } |
| 75 | element = registry.byId('dijit_form_ComboBox_0'); |
| 76 | if(element) { |
| 77 | runner.is("rtl", element.get("textDir"), "widget 'textDir' property should coinside with that of grid"); |
| 78 | } |
| 79 | element = registry.byId('dijit_form_ComboBox_1'); |
| 80 | if(element) { |
| 81 | runner.is("rtl", element.get("textDir"), "widget 'textDir' property should coinside with that of grid"); |
| 82 | } |
| 83 | } |
| 84 | } |
| 85 | ]); |
| 86 | |
| 87 | runner.register("log", function(){ |
| 88 | dom.byId('failures').innerHTML = runner._failureCount; |
| 89 | dom.byId('errors').innerHTML = runner._errorCount; |
| 90 | }); |
| 91 | setTimeout(function(){runner.run();},2000); |
| 92 | }); |
| 93 | }, |
| 94 | addRow = function(){ |
| 95 | test_store.newItem({ |
| 96 | id: dijit.registry.byId("grid").rowCount, |
| 97 | col1: 'new!', |
| 98 | col2: 'new!', |
| 99 | col3: 'new!', |
| 100 | col4: 'new!' |
| 101 | }); |
| 102 | }, |
| 103 | toggleAlwaysEditing = function(){ |
| 104 | var grid = dijit.registry.byId("grid"); |
| 105 | gridLayout[0].defaultCell.alwaysEditing = !gridLayout[0].defaultCell.alwaysEditing; |
| 106 | grid.set('structure', gridLayout); |
| 107 | } |
| 108 | ); |
| 109 | </script> |
| 110 | </head> |
| 111 | <body class="tundra"> |
| 112 | <h1>Grid Edit Controls Bidi Test</h1> |
| 113 | <br /> |
| 114 | <div id="controls"> |
| 115 | <button dojoType="dijit.form.Button" onclick="addRow()">Add Row</button> |
| 116 | <button dojoType="dijit.form.Button" onclick="toggleAlwaysEditing()">Toggle 'alwaysEditing'</button> |
| 117 | </div> |
| 118 | <br /> |
| 119 | <div id="grid" data-dojo-id="grid" data-dojo-type="dojox/grid/DataGrid" |
| 120 | data-dojo-props='textDir: "rtl", store:test_store, rowSelector:"20px", structure:gridLayout, escapeHTMLInData:"false" ' ></div> |
| 121 | <br /> |
| 122 | <div id="rowCount"></div> |
| 123 | |
| 124 | <br>Errors: <span id="errors">?</span> |
| 125 | <br>Failures: <span id="failures">?</span> |
| 126 | </body> |
| 127 | </html> |