Permalink
Browse files

Added a tree test for paging

  • Loading branch information...
1 parent cf787a3 commit 7191c97ab725c4a21fde99d2c9da571c6c5fba16 @kriszyp kriszyp committed Jan 21, 2012
Showing with 12 additions and 5 deletions.
  1. +7 −4 test/JsonRest.html
  2. +5 −1 test/data/rest.php
View
@@ -22,11 +22,14 @@
<script type="text/javascript" src="../../dojo/dojo.js"
data-dojo-config="async: true"></script>
<script type="text/javascript">
- require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Editor", "dgrid/Keyboard", "dojo/_base/declare", "dojo/store/JsonRest", "dojo/store/Observable", "dojo/store/Cache", "dojo/store/Memory", "dojo/domReady!"],
- function(List, Grid, Selection, Editor, Keyboard, declare, JsonRest, Observable, Cache, Memory){
- var testStore = Observable(Cache(JsonRest({target:"./data/rest.php?", idProperty: "id"}), Memory()));
+ require(["dgrid/List", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Editor", "dgrid/Keyboard", "dgrid/Tree", "dojo/_base/declare", "dojo/store/JsonRest", "dojo/store/Observable", "dojo/store/Cache", "dojo/store/Memory", "dojo/domReady!"],
+ function(List, Grid, Selection, Editor, Keyboard, Tree, declare, JsonRest, Observable, Cache, Memory){
+ var testStore = Observable(Cache(JsonRest({target:"./data/rest.php", idProperty: "id"}), Memory()));
+ testStore.getChildren = function(parent, options){
+ return testStore.query({parent: parent.id}, options);
+ };
var columns = [
- {label:'Name', field:'name', sortable: false},
+ Tree({label:'Name', field:'name', sortable: false}),
{label:'Id', field:'id', sortable: false},
Editor({label:'Comment', field:'comment', sortable: false}, "text")
];
View
@@ -1,5 +1,9 @@
<?php
header("Content-Type: application/json");
+$id_prefix = "";
+if(isset($_GET["parent"])){
+ $id_prefix = $_GET["parent"]."-";
+}
if(isset($_SERVER["HTTP_RANGE"])){
preg_match('/(\d+)-(\d+)/',$_SERVER["HTTP_RANGE"], $matches);
@@ -18,7 +22,7 @@
if($i != $start){
echo ',';
}
- echo '{"id":'.$i.',"name":"Item '.$i.'","comment":"hello"}';
+ echo '{"id":"'.$id_prefix.$i.'","name":"Item '.$i.'","comment":"hello"}';
}
echo ']';
?>

0 comments on commit 7191c97

Please sign in to comment.