19 Aug 14:43
Sorting by name in a dijit.Tree?
From: Jette Derriche <jni <at> nerdgirl.dk>
Subject: Sorting by name in a dijit.Tree?
Newsgroups: gmane.comp.web.dojo.user
Date: 2008-08-19 12:47:59 GMT
Subject: Sorting by name in a dijit.Tree?
Newsgroups: gmane.comp.web.dojo.user
Date: 2008-08-19 12:47:59 GMT
Hi
I would like to know if there is a method for sorting children by name,
in a dijit.Tree.
I have figured out how to programmatically add a new child. But I would
also like to sort the children after adding the new child, so that new
'child d' appears after 'child c'.
This is my json data:
{
identifier : 'name',
label : 'name',
items : [
{
name: 'mother',
children: [
{name : 'child a'},
{name : 'child b'},
{name : 'child c'},
{name : 'child e'},
{name : 'child f'}
]
}
]
}
This is how I add a new child...
function addItem(itemName) {
var newItem = dataStore.newItem({ name : itemName });
var childParent;
dataStore.fetchItemByIdentity({
identity : 'mother',
onItem : function (item,request) { childParent = item; }
});
var allChildren = dataStore.getValues(childParent,"children");
dataStore.setValues(childParent,"children",
allChildren.concat(newItem));
}
Kind regards,
Jette
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest <at> dojotoolkit.org
http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
RSS Feed