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