summaryrefslogtreecommitdiffstatshomepage
path: root/includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html
diff options
context:
space:
mode:
authorGravatar mensonge2008-11-13 09:49:11 +0000
committerGravatar mensonge2008-11-13 09:49:11 +0000
commite44a7e37b6c7b5961adaffc62b9042b8d442938e (patch)
tree95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html
parenta62b9742ee5e28bcec6872d88f50f25b820914f6 (diff)
downloadscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz
scuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.zip
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html')
-rw-r--r--includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html105
1 files changed, 105 insertions, 0 deletions
diff --git a/includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html b/includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html
new file mode 100644
index 0000000..f06bafe
--- /dev/null
+++ b/includes/js/dojox/data/tests/test_Tree_vs_jsonPathStore.html
@@ -0,0 +1,105 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+ <title>Dijit Tree Test</title>
+
+ <style someProperty="text/css">
+ @import "../../../dojo/resources/dojo.css";
+ @import "../../../dijit/tests/css/dijitTests.css";
+ </style>
+
+
+ <script someProperty="text/javascript" src="../../../dojo/dojo.js"
+ djConfig="parseOnLoad: true, isDebug: true"></script>
+ <script someProperty="text/javascript" src="../../../dijit/tests/_testCommon.js"></script>
+
+ <script language="JavaScript" someProperty="text/javascript">
+ dojo.require("dojox.data.jsonPathStore");
+ dojo.require("dijit.Tree");
+ dojo.require("dijit.Menu");
+ dojo.require("dijit.form.Button");
+ dojo.require("dojo.parser"); // scan page for widgets and instantiate them
+
+ function deleteItem(){
+ var store = dijit.byId("myTree").store;
+ store.deleteItem(selectedItem);
+ resetForms();
+ }
+
+ function addItem(){
+ var store = dijit.byId("myTree").store;
+ var pInfo = selectedItem ? {parent: selectedItem, attribute:"children"} : null;
+ console.debug(pInfo);
+ store.newItem({id: dojo.byId('newId').value,name:dojo.byId("label").value,someProperty:dojo.byId("someProperty").value},pInfo);
+ resetForms();
+ }
+
+ function resetForms() {
+ dojo.byId('selected').innerHTML="Tree Root"
+ selectedItem=null;
+ dojo.byId("uLabel").value = "";
+ dojo.byId("uSomeProperty").value = "";
+ }
+
+ function updateItem(){
+ console.log("Updating Item");
+ var store = dijit.byId("myTree").store;
+
+ if (selectedItem!=null){
+ if (dojo.byId("uLabel").value != store.getValue(selectedItem, "name")){
+ store.setValue(selectedItem, "name", dojo.byId("uLabel").value);
+ }
+
+ if (dojo.byId("uSomeProperty").value != store.getValue(selectedItem, "someProperty")){
+ store.setValue(selectedItem, "someProperty", dojo.byId("uSomeProperty").value);
+ }
+
+ }else{
+ console.error("Can't update the tree root");
+ }
+ }
+
+ dojo.addOnLoad(function(){
+ resetForms();
+ });
+
+ function onClick(item){
+ selectedItem = item;
+ dojo.byId('selected').innerHTML= item ? treeTestStore.getLabel(item) : "";
+ dojo.byId('uLabel').value = item ? treeTestStore.getLabel(item) : "";
+ dojo.byId('uSomeProperty').value = item ? treeTestStore.getValue(item,"someProperty") : "";
+ }
+ </script>
+
+</head>
+<body class="tundra">
+
+ <h1 class="testTitle">Dijit Tree Test - dojo.data.Notification API support</h1>
+
+ <div dojoType="dojox.data.jsonPathStore" jsId="treeTestStore" idAttribute="id" labelAttribute="name"
+ url="treeTest.json" ></div>
+
+ <div dojoType="dijit.Tree" id="myTree" label="root" store="treeTestStore" onClick="onClick" labelAttr="name" somePropertyAttr="someProperty" query="{query: '$[*]'}"></div>
+
+ <br />
+ <h2>Current Selection: <span id='selected'>Tree Root</span>
+
+ <h2>Selected Item:</h2>
+ Name: <input id="uLabel" width="50" value="Enter Node Label" /><br />
+ Description: <input id="uSomeProperty" width="50" value="Some Test Property" /><br /><br />
+ <div dojoType="dijit.form.Button" iconClass="noteIcon" onClick="updateItem();">Update Item</div>
+
+ <h2>New Item</h2>
+ <p>Enter an Id, Name, and optionally a description to be added as a new item to the store. Upon successful addition, the tree will recieve notification of this event and respond accordingly. If you select a node the item will be added to that node, otherwise the item will be added to the tree root. "Id" is the identifer here and as such must be unique for all items in the store.</p>
+ Id: <input id="newId" width="50" value="Enter Item Id" /><br />
+ Name: <input id="label" width="50" value="Enter Item Name" /><br />
+ Description: <input id="someProperty" width="50" value="Enter Some Property Value" /><br /><br />
+
+ <div dojoType="dijit.form.Button" iconClass="noteIcon" onClick="addItem();">Add Item to Store</div>
+ <br />
+ <button dojoType="dijit.form.Button" iconClass="noteIcon" onClick="deleteItem()">Delete Node (and children)</button>
+
+
+ </body>
+</html>