| 1 | <?xml version="1.0" encoding="UTF-8"?> |
|---|
| 2 | <!DOCTYPE html |
|---|
| 3 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
|---|
| 4 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 5 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|---|
| 6 | |
|---|
| 7 | <head> |
|---|
| 8 | |
|---|
| 9 | <!-- Styles --> |
|---|
| 10 | <style type="text/css"> |
|---|
| 11 | @import "/proserver/dojo/dijit/themes/tundra/tundra.css"; |
|---|
| 12 | @import "/proserver/dojo/dojo/dojo.css"; |
|---|
| 13 | @import "/proserver/dojo/dojox/grid/_grid/Grid.css"; |
|---|
| 14 | |
|---|
| 15 | </style> |
|---|
| 16 | |
|---|
| 17 | <script type="text/javascript" src="/proserver/dojo/dojo/dojo.js.uncompressed.js" djConfig="parseOnLoad: true, isDebug: false"> |
|---|
| 18 | </script> |
|---|
| 19 | |
|---|
| 20 | <!-- Initialize page --> |
|---|
| 21 | <script type="text/javascript"> |
|---|
| 22 | |
|---|
| 23 | dojo.require( "dijit.form.Button" ); |
|---|
| 24 | dojo.require( "dojox.grid.Grid" ); |
|---|
| 25 | dojo.require( "dojox.grid._data.model" ); |
|---|
| 26 | dojo.require( "dojox.grid._data.editors" ); |
|---|
| 27 | dojo.require( "dijit.layout.ContentPane" ); |
|---|
| 28 | dojo.require( "dijit.layout.LayoutContainer" ); |
|---|
| 29 | |
|---|
| 30 | function handleInitPage() |
|---|
| 31 | { |
|---|
| 32 | buildGrid(); |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | dojo.addOnLoad( handleInitPage ); |
|---|
| 36 | |
|---|
| 37 | function buildGrid() |
|---|
| 38 | { |
|---|
| 39 | var gridObject = dijit.byId( "testGrid" ); |
|---|
| 40 | if ( gridObject != null ) |
|---|
| 41 | gridObject.destroy(); |
|---|
| 42 | |
|---|
| 43 | var gridHolderDiv = dojo.byId( "dtGridHolder" ); |
|---|
| 44 | var dtDiv = document.createElement( "div" ); |
|---|
| 45 | gridHolderDiv.appendChild( dtDiv ); |
|---|
| 46 | |
|---|
| 47 | var data = [ [ "one" ], [ "two" ], [ "three" ], [ "four" ] ]; |
|---|
| 48 | var model = new dojox.grid.data.table( null, data ); |
|---|
| 49 | |
|---|
| 50 | var layout = |
|---|
| 51 | [ |
|---|
| 52 | { type: 'dojox.GridRowView', width: '20px' }, |
|---|
| 53 | { rows: |
|---|
| 54 | [[ { name: 'Value', width: 14, editor: dojox.grid.editors.Input } |
|---|
| 55 | ]] |
|---|
| 56 | } |
|---|
| 57 | ]; |
|---|
| 58 | |
|---|
| 59 | gridObject = new dojox.Grid( |
|---|
| 60 | { |
|---|
| 61 | id : "testGrid", |
|---|
| 62 | model : model, |
|---|
| 63 | structure : layout, |
|---|
| 64 | singleClickEdit : true |
|---|
| 65 | }, |
|---|
| 66 | dtDiv |
|---|
| 67 | ); |
|---|
| 68 | gridObject.render(); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | function addDataValue() |
|---|
| 72 | { |
|---|
| 73 | var grid = dijit.byId( "testGrid" ); |
|---|
| 74 | var rowCount = grid.model.getRowCount(); |
|---|
| 75 | grid.addRow( [ "New Value" ], rowCount ); |
|---|
| 76 | grid.selection.select( rowCount ); |
|---|
| 77 | var cell = grid.getCell( 0 ); |
|---|
| 78 | grid.edit.setEditCell( cell, rowCount ); |
|---|
| 79 | } |
|---|
| 80 | </script> |
|---|
| 81 | |
|---|
| 82 | </head> |
|---|
| 83 | |
|---|
| 84 | <body class="tundra"> |
|---|
| 85 | |
|---|
| 86 | <table cellpadding="2" cellspacing="2"> |
|---|
| 87 | <tr> |
|---|
| 88 | <td> |
|---|
| 89 | <table cellspacing="0" cellpadding="0"> |
|---|
| 90 | <tr> |
|---|
| 91 | <td align="right"> |
|---|
| 92 | <table> |
|---|
| 93 | <tr> |
|---|
| 94 | <td><button dojoType="dijit.form.Button" id="dtpvAdd" iconClass="dijitEditorIcon dijitEditorIconCopy" onclick="addDataValue()"></button></td> |
|---|
| 95 | </tr> |
|---|
| 96 | </table> |
|---|
| 97 | </td> |
|---|
| 98 | </tr> |
|---|
| 99 | <tr> |
|---|
| 100 | <td> |
|---|
| 101 | <div dojoType="dijit.layout.LayoutContainer" |
|---|
| 102 | id="dtGridHolder" |
|---|
| 103 | class="dijitTextArea" |
|---|
| 104 | style="position: relative; width: 205px; height: 120px; text-align:left; overflow:hidden;"> |
|---|
| 105 | </div> |
|---|
| 106 | </td> |
|---|
| 107 | </tr> |
|---|
| 108 | </table> |
|---|
| 109 | |
|---|
| 110 | </td> |
|---|
| 111 | </tr> |
|---|
| 112 | </table> |
|---|
| 113 | |
|---|
| 114 | </body> |
|---|
| 115 | |
|---|
| 116 | </html> |
|---|