A common scenario in line-of-business applications is the need to create master-detail forms. The DataView control makes this very easy; let's see how:
Replace the existing <script> block with the following:
<script type="text/javascript"> Sys.require([Sys.components.dataView], function() { var people = [ { Name: "Alex Mackey", Age: "28", Address: "20 Tree road", Telephone: "888888" }, { Name: "Sharyn Mackey", Age: "35", Address: "10 Oak ave", Telephone: "777777" }, { Name: "Brett Chaney", Age: "33", Address: "50 Wayside Road", Telephone: "6666666" }, { Name: "Jenny Chia", Age: "24", Address: "88 Burleigh Gardens", Telephone: "5555555" } ]; var master = Sys.create.dataView('#peoplesNames', { data: people }); var detail = Sys.create.dataView("#peopleDetail"); Sys.bind(detail, "data", master, "selectedData"); }); </script>
Now replace the <body> section with the following code:
<body> <div id="peoplesNames" class="sys-template"> <div class="dataItem" sys:command="select"> {{ Name }} <hr /> </div> </div> <!--Detail View--> <div id="peopleDetail" class="sys-template"> <span class="nameddetailitem"> Age: {{ Age }} <br /> Address: {{ Address }} <br /> Telephone: {{ Telephone }} </span> </div> </body>
That's it. Run the code, click a name, and see that the individual's details are retrieved. Note the line Sys.bind(detail, "data", master, "selectedData") that links the master and detail DataViews together.
3.143.5.131