source: Dev/branches/rest-dojo-ui/client/dijit/tests/tree/CustomLabel.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 3.2 KB
Line 
1<!DOCTYPE html>
2<html>
3<head>
4        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5        <title>Dijit Tree Custom Label Test</title>
6
7        <style type="text/css">
8                @import "../../themes/claro/document.css";
9                @import "../css/dijitTests.css";
10        </style>
11
12        <!-- required: a default dijit theme: -->
13        <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/>
14
15        <!-- required: dojo.js -->
16        <script type="text/javascript" src="../../../dojo/dojo.js"
17                data-dojo-config="parseOnLoad: true, isDebug: true"></script>
18
19        <!-- not needed, for testing alternate themes -->
20        <script type="text/javascript" src="../_testCommon.js"></script>
21
22        <script type="text/javascript">
23                dojo.require("doh.runner");
24                dojo.require("dijit.dijit"); // optimize: load dijit layer
25                dojo.require("dojo.data.ItemFileReadStore");
26                dojo.require("dijit.Tree");
27                dojo.require("dijit.tree.ForestStoreModel");
28                dojo.require("dojo.parser");    // scan page for widgets and instantiate them
29               
30                dojo.ready(function(){
31                        doh.register("Test custom label",
32                                [
33                                        {
34                                                name: "testLabels",
35                                                timeout: 1000,
36                                                runTest: function(){
37                                                        var d = new doh.Deferred();
38
39                                                        setTimeout(d.getTestCallback(function(){
40                                                                var nameTree = dijit.byId("nameTree");
41                                                                var nameChildren = nameTree.rootNode.getChildren();
42                                                                doh.is("Arizona", nameChildren[3].label);
43                                                                doh.is("Colorado", nameChildren[9].label);
44                                                               
45                                                                var codeTree = dijit.byId("codeTree");
46                                                                var codeChildren = codeTree.rootNode.getChildren();
47                                                                doh.is("AZ", codeChildren[3].label);
48                                                                doh.is("CO", codeChildren[9].label);
49                                                               
50                                                                var customTree = dijit.byId("customTree");
51                                                                var customChildren = customTree.rootNode.getChildren();
52                                                                doh.is("Arizona (AZ)", customChildren[3].label);
53                                                                doh.is("Colorado (CO)", customChildren[9].label);
54                                                        }), 500);
55                                                       
56                                                        return d;
57                                                }
58                                        }
59                                ]
60                        );
61
62                        doh.run();
63                });
64
65        </script>
66</head>
67<body class="claro">
68
69        <h1 class="testTitle">Dijit Tree Custom Label Test</h1>
70
71        <div data-dojo-id="store" data-dojo-type="dojo.data.ItemFileReadStore" data-dojo-props='url:"../_data/states.json"'></div>
72
73        <h2>Standard label (state names)</h2>
74        <div data-dojo-id="nameModel" data-dojo-type="dijit.tree.ForestStoreModel" data-dojo-props='store:store, rootLabel:"States"'></div>
75        <div id="nameTree" data-dojo-type="dijit.Tree" data-dojo-props='model:nameModel, openOnClick:true'></div>
76
77        <h2>LabelAttr (state abbreviation)</h2>
78        <div data-dojo-id="codeModel" data-dojo-type="dijit.tree.ForestStoreModel" data-dojo-props='store:store, rootLabel:"States", labelAttr:"abbreviation"'></div>
79        <div id="codeTree" data-dojo-type="dijit.Tree" data-dojo-props='model:codeModel, openOnClick:true'></div>
80
81        <h2>Custom label via callback</h2>
82        <div data-dojo-id="customModel" data-dojo-type="dijit.tree.ForestStoreModel" data-dojo-props='store:store'>
83                <script type="dojo/method" data-dojo-event="getLabel" data-dojo-args="item">
84                        if(item.root){ return "States"; }
85                        return (store.getLabel(item) + " (" + store.getIdentity(item) + ")");
86                </script>
87        </div>
88        <div id="customTree" data-dojo-type="dijit.Tree" data-dojo-props='model:customModel, openOnClick:true'></div>
89
90
91</body>
92</html>
Note: See TracBrowser for help on using the repository browser.