Updated
This commit is contained in:
118
master/examples/test_edit_keyNav.html
Normal file
118
master/examples/test_edit_keyNav.html
Normal file
@@ -0,0 +1,118 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<title>Test dojox.grid.DataGrid Editing</title>
|
||||
<style>
|
||||
@import "../resources/Grid.css";
|
||||
body {
|
||||
font-family: Tahoma, Arial, Helvetica, sans-serif;
|
||||
font-size: 11px;
|
||||
}
|
||||
.dojoxGridRowEditing td {
|
||||
background-color: #F4FFF4;
|
||||
}
|
||||
.dojoxGrid input, .dojoxGrid select, .dojoxGrid textarea {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
width: 100%;
|
||||
font-size: 100%;
|
||||
font-family: inherit;
|
||||
}
|
||||
.dojoxGrid input {
|
||||
}
|
||||
.dojoxGrid select {
|
||||
}
|
||||
.dojoxGrid textarea {
|
||||
}
|
||||
#controls {
|
||||
padding: 6px 0;
|
||||
}
|
||||
#grid {
|
||||
width: 850px;
|
||||
height: 350px;
|
||||
border: 1px solid silver;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:false, parseOnLoad: true"></script>
|
||||
<script type="text/javascript">
|
||||
dojo.require("dojox.grid.DataGrid");
|
||||
dojo.require("dojo.data.ItemFileWriteStore");
|
||||
dojo.require("dojo.parser");
|
||||
</script>
|
||||
<script type="text/javascript" src="support/test_data.js"></script>
|
||||
<script type="text/javascript">
|
||||
// ==========================================================================
|
||||
// Custom formatter
|
||||
// ==========================================================================
|
||||
formatMoney = function(inDatum) {
|
||||
return isNaN(inDatum) ? '...' : '$' + parseFloat(inDatum).toFixed(2);
|
||||
}
|
||||
// ==========================================================================
|
||||
// Grid structure
|
||||
// ==========================================================================
|
||||
statusCell = { field: 'col3', name: 'Status', styles: 'text-align: center;', type: dojox.grid.cells.Select, options: [ "new", "read", "replied" ] };
|
||||
gridLayout = [{
|
||||
defaultCell: { width: 8, editable: true, styles: 'text-align: right;' },
|
||||
cells: [
|
||||
{ name: 'Id', field: 'id', width: 3, editable: false },
|
||||
{ name: 'Priority', field: 'col1', styles: 'text-align: center;', type: dojox.grid.cells.Select, options: ["normal", "note", "important"] },
|
||||
{ name: 'Mark', width: 3, field: 'col2', styles: 'text-align: center;', type: dojox.grid.cells.Bool },
|
||||
statusCell,
|
||||
{ name: 'Message', field: 'col4', styles: '', width: '100%' },
|
||||
{ name: 'Amount1', field: 'col5', formatter: formatMoney },
|
||||
{ name: 'Amount2', field: 'col6', editable: false, formatter: formatMoney }
|
||||
]
|
||||
},{
|
||||
defaultCell: { width: 4, editable: true, styles: 'text-align: right;' },
|
||||
rows: [
|
||||
{ name: 'Mark', width: 3, field: 'col2', styles: 'text-align: center;', type: dojox.grid.cells.Bool},
|
||||
statusCell,
|
||||
{ name: 'Amount3', field: 'col5', editable: false, formatter: formatMoney},
|
||||
{ name: 'Detail', value: 'Detail', editable: false}
|
||||
]
|
||||
}];
|
||||
// ==========================================================================
|
||||
// UI Action
|
||||
// ==========================================================================
|
||||
addRow = function(){
|
||||
test_store.newItem({
|
||||
id: grid.rowCount,
|
||||
col1: 'normal',
|
||||
col2: false,
|
||||
col3: 'new',
|
||||
col4: 'Now is the time for all good men to come to the aid of their party.',
|
||||
col5: 99.99,
|
||||
col6: 9.99,
|
||||
col7: false
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h2>
|
||||
dojox.grid.DataGrid Basic Editing and Key Navigation test
|
||||
</h2>
|
||||
<div id="controls">
|
||||
<button onclick="grid.render()">Refresh</button>
|
||||
<button onclick="grid.edit.focusEditor()">Focus Editor</button>
|
||||
<button onclick="grid.focus.next()">Next Focus</button>
|
||||
<button onclick="addRow()">Add Row</button>
|
||||
<button onclick="grid.removeSelectedRows()">Remove</button>
|
||||
<button onclick="grid.edit.apply()">Apply</button>
|
||||
<button onclick="grid.edit.cancel()">Cancel</button>
|
||||
<button onclick="grid.singleClickEdit = !grid.singleClickEdit">Toggle singleClickEdit</button>
|
||||
</div>
|
||||
<p>Id, Priority, Mark, Status, Message, Amount1, second Mark, second Status fields are editable, Amount2,
|
||||
Amount3, and detail field are not editable. Once in edit mode you can tab and shift-tab between
|
||||
editable fields and remain in edit mode. Pressing escape leaves edit mode and arrow keys will again move
|
||||
between cells. </p>
|
||||
<div id="grid" dojoType="dojox.grid.DataGrid"
|
||||
jsId="grid"
|
||||
rowSelector="20px"
|
||||
store="test_store" structure="gridLayout"></div>
|
||||
<br />
|
||||
<div id="rowCount"></div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user