| 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 | <title>Test dojox.grid.DataGrid Editing</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../resources/Grid.css"; |
| 8 | @import "../resources/tundraGrid.css"; |
| 9 | @import "../../../dojo/resources/dojo.css"; |
| 10 | @import "../../../dijit/themes/tundra/tundra.css"; |
| 11 | @import "../../../dijit/tests/css/dijitTests.css"; |
| 12 | |
| 13 | .dojoxGridRowEditing td { |
| 14 | background-color: #F4FFF4; |
| 15 | } |
| 16 | .dojoxGrid input, .dojoxGrid select, .dojoxGrid textarea { |
| 17 | margin: 0; |
| 18 | padding: 0; |
| 19 | border-style: none; |
| 20 | width: 100%; |
| 21 | font-size: 100%; |
| 22 | font-family: inherit; |
| 23 | } |
| 24 | .dojoxGrid input { } |
| 25 | .dojoxGrid select { } |
| 26 | .dojoxGrid textarea { } |
| 27 | |
| 28 | #controls { |
| 29 | padding: 6px 0; |
| 30 | } |
| 31 | #controls button { |
| 32 | margin-left: 10px; |
| 33 | } |
| 34 | .myGrid { |
| 35 | width: 850px; |
| 36 | height: 350px; |
| 37 | border: 1px solid silver; |
| 38 | } |
| 39 | </style> |
| 40 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 41 | data-dojo-config="isDebug:false, parseOnLoad: true"></script> |
| 42 | <script type="text/javascript"> |
| 43 | dojo.require("dijit.dijit"); |
| 44 | dojo.require("dojox.grid.DataGrid"); |
| 45 | dojo.require("dojo.data.ItemFileWriteStore"); |
| 46 | dojo.require("dojo.parser"); |
| 47 | </script> |
| 48 | <script type="text/javascript" src="support/test_data.js"></script> |
| 49 | <script type="text/javascript"> |
| 50 | // ========================================================================== |
| 51 | // Custom formatter |
| 52 | // ========================================================================== |
| 53 | formatMoney = function(inDatum){ |
| 54 | return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2); |
| 55 | } |
| 56 | |
| 57 | // ========================================================================== |
| 58 | // Grid structure |
| 59 | // ========================================================================== |
| 60 | selectCell = { |
| 61 | styles: 'text-align: center;', |
| 62 | type: dojox.grid.cells.Select |
| 63 | }; |
| 64 | |
| 65 | gridLayout = { |
| 66 | defaultCell: { width: 8, editable: true, styles: 'text-align: right;' }, |
| 67 | rows: [ |
| 68 | [ |
| 69 | { name: 'Id', width: 3, field: 'id' }, |
| 70 | dojo.mixin({}, selectCell, { |
| 71 | name: 'Priority', field: 'col1', options: [ 'normal', 'note', 'important' ] |
| 72 | }), |
| 73 | { name: 'Mark', width: 3, field: 'col2', styles: 'text-align: center;', type: dojox.grid.cells.Bool }, |
| 74 | dojo.mixin({}, selectCell, { |
| 75 | name: 'Status', field: 'col3', options: [ 'new', 'read', 'replied' ] |
| 76 | }), |
| 77 | { name: 'Message', field: 'col4', styles: '', width: '100%' }, |
| 78 | { name: 'Amount', field: 'col5', formatter: formatMoney } |
| 79 | ] |
| 80 | ] |
| 81 | }; |
| 82 | // ========================================================================== |
| 83 | // UI Action |
| 84 | // ========================================================================== |
| 85 | addRow = function() { |
| 86 | test_store.newItem({ |
| 87 | id: grid.rowCount, |
| 88 | col1: 'normal', |
| 89 | col2: false, |
| 90 | col3: 'new', |
| 91 | col4: 'Now is the time for all good men to come to the aid of their party.', |
| 92 | col5: 99.99, |
| 93 | col6: 9.99, |
| 94 | col7: false |
| 95 | }); |
| 96 | } |
| 97 | </script> |
| 98 | </head> |
| 99 | <body class="tundra"> |
| 100 | <h1>dojox.grid.DataGrid Basic Editing test</h1> |
| 101 | <br /> |
| 102 | <div id="controls"> |
| 103 | <button onclick="grid.render()">Refresh</button> |
| 104 | <button onclick="grid.edit.focusEditor()">Focus Editor</button> |
| 105 | <button onclick="grid.focus.next()">Next Focus</button> |
| 106 | <button onclick="addRow()">Add Row</button> |
| 107 | <button onclick="grid.removeSelectedRows()">Remove</button> |
| 108 | <button onclick="grid.edit.apply()">Apply</button> |
| 109 | <button onclick="grid.edit.cancel()">Cancel</button> |
| 110 | <button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button> |
| 111 | </div> |
| 112 | <br /> |
| 113 | <div data-dojo-id="grid" class="myGrid" |
| 114 | dojoType="dojox.grid.DataGrid" store="test_store" |
| 115 | structure="gridLayout" rowSelector="20px"></div> |
| 116 | <br /> |
| 117 | <div id="rowCount"></div> |
| 118 | </body> |
| 119 | </html> |