| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>Static Master/Detail Pattern -- Search Results example, using a store with save, commit and reset</title> |
| 6 |
|
| 7 |
<style type="text/css"> |
| 8 |
@import "css/app-format.css"; |
| 9 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 10 |
</style> |
| 11 |
<script type="text/javascript" djConfig="parseOnLoad:0,isDebug:1,async:1" src="../../../../dojo/dojo.js"></script> |
| 12 |
<script type="text/javascript"> |
| 13 |
var results, selectedIndex = 0; |
| 14 |
|
| 15 |
require([ |
| 16 |
'dojo/_base/kernel', |
| 17 |
'dojo/parser', |
| 18 |
'dojox/mvc', |
| 19 |
'dojo/data/ItemFileWriteStore', |
| 20 |
'dojo/store/DataStore', |
| 21 |
'dijit/form/TextBox', |
| 22 |
'dijit/form/Button', |
| 23 |
'dojox/mvc/Repeat', |
| 24 |
'dojox/mvc/Group', |
| 25 |
'dojox/mvc/Output' |
| 26 |
], function(kernel, parser, mvc, ItemFileWriteStore, DataStore){ |
| 27 |
var writeStore = new ItemFileWriteStore({url: kernel.moduleUrl("dojox.mvc.tests._data", "mvcRepeatData.json")}); |
| 28 |
var modelPromise = mvc.newStatefulModel({store: new DataStore({store: writeStore})}); |
| 29 |
modelPromise.then(function(model){ |
| 30 |
results = model; |
| 31 |
parser.parse(); |
| 32 |
}); |
| 33 |
}); |
| 34 |
|
| 35 |
// called to change the selected item |
| 36 |
function setDetailsContext(index) { |
| 37 |
selectedIndex = index; |
| 38 |
var widget = dijit.byId("detailsGroup"); |
| 39 |
widget.set("ref", index); |
| 40 |
}; |
| 41 |
</script> |
| 42 |
</head> |
| 43 |
<body class="claro" style="background-image: url(images/master_detail.png)"> |
| 44 |
<div id="wrapper"> |
| 45 |
<div id="header"> |
| 46 |
<div id="navigation"> |
| 47 |
</div> |
| 48 |
<div id="headerInsert"> |
| 49 |
<h2>Master Detail Example - With repeat container, using a store, with save, commit and reset.</h2> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<div id="main"> |
| 53 |
<div id="leftNav"> |
| 54 |
</div> |
| 55 |
<div id="mainContent"> |
| 56 |
<div id="searchBanner">Search Results for term: </div> |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
<div id="repeatId" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'results'"> |
| 64 |
<div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'"> |
| 65 |
<label class="cell" for="nameInput${this.index}">Name:</label> |
| 66 |
<input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"></input> |
| 67 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<div class="spacer"></div> |
| 71 |
|
| 72 |
<div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'results'"> |
| 73 |
<div id="detailsBanner">Details for selected index:</div> |
| 74 |
|
| 75 |
<div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'"> |
| 76 |
<div class="row"> |
| 77 |
<label class="cell" for="firstInput">First Name:</label> |
| 78 |
<input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"></input> |
| 79 |
</div> |
| 80 |
<div class="row"> |
| 81 |
<label class="cell" for="lastInput">Last Name:</label> |
| 82 |
<input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"></input> |
| 83 |
</div> |
| 84 |
<div class="row"> |
| 85 |
<label class="cell" for="locationInput">Location:</label> |
| 86 |
<input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"></input> |
| 87 |
</div> |
| 88 |
<div class="row"> |
| 89 |
<label class="cell" for="officeInput">Office:</label> |
| 90 |
<input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"></input> |
| 91 |
</div> |
| 92 |
<div class="row"> |
| 93 |
<label class="cell" for="emailInput">Email:</label> |
| 94 |
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"></input> |
| 95 |
</div> |
| 96 |
<div class="row"> |
| 97 |
<label class="cell" for="telInput">Telephone:</label> |
| 98 |
<input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"></input> |
| 99 |
</div> |
| 100 |
<div class="row"> |
| 101 |
<label class="cell" for="faxInput">Fax:</label> |
| 102 |
<input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"></input> |
| 103 |
</div> |
| 104 |
<div class="row"> |
| 105 |
<div class="spacer"></div> |
| 106 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){console.log(results[selectedIndex].toPlainObject());results[selectedIndex].commit();}">Save Item</button> |
| 107 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){console.log(results.toPlainObject());results.commit();;}">Commit All</button> |
| 108 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){results.reset();}">Reset to last saved</button> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
</div> |
| 114 |
</div> |
| 115 |
</body> |
| 116 |
</html> |