Files
openlayers/master/examples/test_mvc_repeat-declarative-sync.html
Éric Lemoine 5d14b9e2d4 Updated
2013-02-20 10:38:25 +01:00

206 lines
7.2 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Static Master/Detail Pattern -- Search Results example, declarative with save, commit and reset</title>
<script src="../../../dojo/dojo.js"
type="text/javascript"
djConfig="parseOnLoad: true, isDebug: true">
</script>
<style type="text/css">
@import "css/app-format.css";
@import "../../../dijit/themes/claro/claro.css";
</style>
<script type="text/javascript" >
dojo.require("dojox.mvc");
dojo.require("dojox.mvc.Group");
dojo.require("dojox.mvc.Repeat");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Button");
dojo.require("dojo.parser");
// Raw records for the master detail
var search_results_init =
{
"Results" : [
{
"First" : "Anne",
"Last" : "Ackerman",
"Location": "NY",
"Office" : "1S76",
"Email" : "a.a@test.com",
"Tel" : "123-764-8237",
"Fax" : "123-764-8228"
},
{
"First" : "Ben",
"Last" : "Beckham",
"Location": "NY",
"Office" : "5N47",
"Email" : "b.b@test.com",
"Tel" : "123-764-8599",
"Fax" : "123-764-8600"
},
{
"First" : "Chad",
"Last" : "Chapman",
"Location": "CA",
"Office" : "1278",
"Email" : "c.c@test.com",
"Tel" : "408-764-8237",
"Fax" : "408-764-8228"
},
{
"First" : "David",
"Last" : "Durham",
"Location": "NJ",
"Office" : "C12",
"Email" : "d.d@test.com",
"Tel" : "514-764-8237",
"Fax" : "514-764-8228"
},
{
"First" : "Emma",
"Last" : "Eklof",
"Location": "NY",
"Office" : "4N76",
"Email" : "e.e@test.com",
"Tel" : "123-764-1234",
"Fax" : "123-764-4321"
},
{
"First" : "Fred",
"Last" : "Fisher",
"Location": "NJ",
"Office" : "V89",
"Email" : "f.f@test.com",
"Tel" : "514-764-8567",
"Fax" : "514-764-8000"
},
{
"First" : "George",
"Last" : "Garnett",
"Location": "NY",
"Office" : "7S11",
"Email" : "gig@test.com",
"Tel" : "123-999-8599",
"Fax" : "123-999-8600"
},
{
"First" : "Hunter",
"Last" : "Huffman",
"Location": "CA",
"Office" : "6532",
"Email" : "h.h@test.com",
"Tel" : "408-874-8237",
"Fax" : "408-874-8228"
},
{
"First" : "Irene",
"Last" : "Ira",
"Location": "NJ",
"Office" : "F09",
"Email" : "i.i@test.com",
"Tel" : "514-764-6532",
"Fax" : "514-764-7300"
},
{
"First" : "John",
"Last" : "Jacklin",
"Location": "CA",
"Office" : "6701",
"Email" : "j.j@test.com",
"Tel" : "408-764-1234",
"Fax" : "408-764-4321"
}
]
};
var selectedIndex = 0;
</script>
</head>
<body class="claro" style="background-image: url(images/master_detail.png)">
<div data-dojo-id="results" data-dojo-type="dojox.mvc.StatefulModel" data="search_results_init" ></div>
<div id="wrapper">
<div id="header">
<div id="navigation">
</div>
<div id="headerInsert">
<h2>Master Detail Example - Declarative with repeat container, with save, commit and reset.</h2>
</div>
</div>
<div id="main">
<div id="leftNav">
</div>
<div id="mainContent">
<div id="searchBanner">Search Results for term: </div>
<!--
The repeat container denotes a templated UI that operates over a collection
of data records.
The UI can be customized for each iteration using properties such as
${this.index} for the iteration index.
-->
<div id="repeatId" data-dojo-type="dojox.mvc.Repeat" data-dojo-props="ref: 'results.Results'">
<div class="row" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '${this.index}'">
<label class="cell" for="nameInput${this.index}">Name:</label>
<input class="cell" data-dojo-type="dijit.form.TextBox" id="nameInput${this.index}" data-dojo-props="ref: 'First'"></input>
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){setDetailsContext('${this.index}');}">Details</button>
</div>
</div>
<div class="spacer"></div>
<div data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: 'results.Results'">
<div id="detailsBanner">Details for selected index:</div>
<div id="detailsGroup" data-dojo-type="dojox.mvc.Group" data-dojo-props="ref: '0'">
<div class="row">
<label class="cell" for="firstInput">First Name:</label>
<input class="cell" id="firstInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'First'"></input>
</div>
<div class="row">
<label class="cell" for="lastInput">Last Name:</label>
<input class="cell" id="lastInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Last'"></input>
</div>
<div class="row">
<label class="cell" for="locationInput">Location:</label>
<input class="cell" id="locationInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Location'"></input>
</div>
<div class="row">
<label class="cell" for="officeInput">Office:</label>
<input class="cell" id="officeInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Office'"></input>
</div>
<div class="row">
<label class="cell" for="emailInput">Email:</label>
<input class="cell" id="emailInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Email'"></input>
</div>
<div class="row">
<label class="cell" for="telInput">Telephone:</label>
<input class="cell" id="telInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Tel'"></input>
</div>
<div class="row">
<label class="cell" for="faxInput">Fax:</label>
<input class="cell" id="faxInput" data-dojo-type="dijit.form.TextBox" data-dojo-props="ref: 'Fax'"></input>
</div>
<div class="row">
<div class="spacer"></div>
<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>
<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>
<button type="button" data-dojo-type="dijit.form.Button" data-dojo-props="onClick: function(){results.Results.reset();}">Reset to last saved</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
// called to change the selected item
function setDetailsContext(index) {
selectedIndex = index;
var widget = dijit.byId("detailsGroup");
widget.set("ref", index);
};
</script>
</body>
</html>