| 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, declarative with save, commit and reset</title> |
| 6 |
|
| 7 |
<script src="../../../../dojo/dojo.js" |
| 8 |
type="text/javascript" |
| 9 |
djConfig="parseOnLoad: true, isDebug: true"> |
| 10 |
</script> |
| 11 |
<style type="text/css"> |
| 12 |
@import "css/app-format.css"; |
| 13 |
@import "../../../../dijit/themes/claro/claro.css"; |
| 14 |
</style> |
| 15 |
<script type="text/javascript" > |
| 16 |
dojo.require("dojox.mvc"); |
| 17 |
dojo.require("dojox.mvc.Group"); |
| 18 |
dojo.require("dojox.mvc.Repeat"); |
| 19 |
dojo.require("dijit.form.TextBox"); |
| 20 |
dojo.require("dijit.form.Button"); |
| 21 |
dojo.require("dojo.parser"); |
| 22 |
|
| 23 |
// Raw records for the master detail |
| 24 |
var search_results_init = |
| 25 |
{ |
| 26 |
"Results" : [ |
| 27 |
{ |
| 28 |
"First" : "Anne", |
| 29 |
"Last" : "Ackerman", |
| 30 |
"Location": "NY", |
| 31 |
"Office" : "1S76", |
| 32 |
"Email" : "[email protected]", |
| 33 |
"Tel" : "123-764-8237", |
| 34 |
"Fax" : "123-764-8228" |
| 35 |
}, |
| 36 |
{ |
| 37 |
"First" : "Ben", |
| 38 |
"Last" : "Beckham", |
| 39 |
"Location": "NY", |
| 40 |
"Office" : "5N47", |
| 41 |
"Email" : "[email protected]", |
| 42 |
"Tel" : "123-764-8599", |
| 43 |
"Fax" : "123-764-8600" |
| 44 |
}, |
| 45 |
{ |
| 46 |
"First" : "Chad", |
| 47 |
"Last" : "Chapman", |
| 48 |
"Location": "CA", |
| 49 |
"Office" : "1278", |
| 50 |
"Email" : "[email protected]", |
| 51 |
"Tel" : "408-764-8237", |
| 52 |
"Fax" : "408-764-8228" |
| 53 |
}, |
| 54 |
{ |
| 55 |
"First" : "David", |
| 56 |
"Last" : "Durham", |
| 57 |
"Location": "NJ", |
| 58 |
"Office" : "C12", |
| 59 |
"Email" : "[email protected]", |
| 60 |
"Tel" : "514-764-8237", |
| 61 |
"Fax" : "514-764-8228" |
| 62 |
}, |
| 63 |
{ |
| 64 |
"First" : "Emma", |
| 65 |
"Last" : "Eklof", |
| 66 |
"Location": "NY", |
| 67 |
"Office" : "4N76", |
| 68 |
"Email" : "[email protected]", |
| 69 |
"Tel" : "123-764-1234", |
| 70 |
"Fax" : "123-764-4321" |
| 71 |
}, |
| 72 |
{ |
| 73 |
"First" : "Fred", |
| 74 |
"Last" : "Fisher", |
| 75 |
"Location": "NJ", |
| 76 |
"Office" : "V89", |
| 77 |
"Email" : "[email protected]", |
| 78 |
"Tel" : "514-764-8567", |
| 79 |
"Fax" : "514-764-8000" |
| 80 |
}, |
| 81 |
{ |
| 82 |
"First" : "George", |
| 83 |
"Last" : "Garnett", |
| 84 |
"Location": "NY", |
| 85 |
"Office" : "7S11", |
| 86 |
"Email" : "[email protected]", |
| 87 |
"Tel" : "123-999-8599", |
| 88 |
"Fax" : "123-999-8600" |
| 89 |
}, |
| 90 |
{ |
| 91 |
"First" : "Hunter", |
| 92 |
"Last" : "Huffman", |
| 93 |
"Location": "CA", |
| 94 |
"Office" : "6532", |
| 95 |
"Email" : "[email protected]", |
| 96 |
"Tel" : "408-874-8237", |
| 97 |
"Fax" : "408-874-8228" |
| 98 |
}, |
| 99 |
{ |
| 100 |
"First" : "Irene", |
| 101 |
"Last" : "Ira", |
| 102 |
"Location": "NJ", |
| 103 |
"Office" : "F09", |
| 104 |
"Email" : "[email protected]", |
| 105 |
"Tel" : "514-764-6532", |
| 106 |
"Fax" : "514-764-7300" |
| 107 |
}, |
| 108 |
{ |
| 109 |
"First" : "John", |
| 110 |
"Last" : "Jacklin", |
| 111 |
"Location": "CA", |
| 112 |
"Office" : "6701", |
| 113 |
"Email" : "[email protected]", |
| 114 |
"Tel" : "408-764-1234", |
| 115 |
"Fax" : "408-764-4321" |
| 116 |
} |
| 117 |
] |
| 118 |
}; |
| 119 |
|
| 120 |
var selectedIndex = 0; |
| 121 |
</script> |
| 122 |
</head> |
| 123 |
<body class="claro" style="background-image: url(images/master_detail.png)"> |
| 124 |
<div data-dojo-id="results" data-dojo-type="dojox.mvc.StatefulModel" data="search_results_init" ></div> |
| 125 |
<div id="wrapper"> |
| 126 |
<div id="header"> |
| 127 |
<div id="navigation"> |
| 128 |
</div> |
| 129 |
<div id="headerInsert"> |
| 130 |
<h2>Master Detail Example - Declarative with repeat container, with save, commit and reset.</h2> |
| 131 |
</div> |
| 132 |
</div> |
| 133 |
<div id="main"> |
| 134 |
<div id="leftNav"> |
| 135 |
</div> |
| 136 |
<div id="mainContent"> |
| 137 |
<div id="searchBanner">Search Results for term: </div> |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
<div id="repeatId" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'results.Results'"> |
| 145 |
<div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'"> |
| 146 |
<label class="cell" for="nameInput${this.index}">Name:</label> |
| 147 |
<input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"></input> |
| 148 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button> |
| 149 |
</div> |
| 150 |
</div> |
| 151 |
<div class="spacer"></div> |
| 152 |
|
| 153 |
<div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'results.Results'"> |
| 154 |
<div id="detailsBanner">Details for selected index:</div> |
| 155 |
|
| 156 |
<div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'"> |
| 157 |
<div class="row"> |
| 158 |
<label class="cell" for="firstInput">First Name:</label> |
| 159 |
<input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"></input> |
| 160 |
</div> |
| 161 |
<div class="row"> |
| 162 |
<label class="cell" for="lastInput">Last Name:</label> |
| 163 |
<input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"></input> |
| 164 |
</div> |
| 165 |
<div class="row"> |
| 166 |
<label class="cell" for="locationInput">Location:</label> |
| 167 |
<input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"></input> |
| 168 |
</div> |
| 169 |
<div class="row"> |
| 170 |
<label class="cell" for="officeInput">Office:</label> |
| 171 |
<input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"></input> |
| 172 |
</div> |
| 173 |
<div class="row"> |
| 174 |
<label class="cell" for="emailInput">Email:</label> |
| 175 |
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"></input> |
| 176 |
</div> |
| 177 |
<div class="row"> |
| 178 |
<label class="cell" for="telInput">Telephone:</label> |
| 179 |
<input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"></input> |
| 180 |
</div> |
| 181 |
<div class="row"> |
| 182 |
<label class="cell" for="faxInput">Fax:</label> |
| 183 |
<input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"></input> |
| 184 |
</div> |
| 185 |
<div class="row"> |
| 186 |
<div class="spacer"></div> |
| 187 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){console.log(results.Results[selectedIndex].toPlainObject());results.Results[selectedIndex].commit();}">Save Item</button> |
| 188 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){console.log(results.Results.toPlainObject());results.Results.commit();;}">Commit All</button> |
| 189 |
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){results.Results.reset();}">Reset to last saved</button> |
| 190 |
</div> |
| 191 |
</div> |
| 192 |
</div> |
| 193 |
</div> |
| 194 |
</div> |
| 195 |
</div> |
| 196 |
<script type="text/javascript"> |
| 197 |
// called to change the selected item |
| 198 |
function setDetailsContext(index) { |
| 199 |
selectedIndex = index; |
| 200 |
var widget = dijit.byId("detailsGroup"); |
| 201 |
widget.set("ref", index); |
| 202 |
}; |
| 203 |
</script> |
| 204 |
</body> |
| 205 |
</html> |