picture

Archive for the ‘JavaScript’ Category

Dojo: hasDownArrow property of dijit.form.FilteringSelect

Monday, March 12th, 2012

If set to false the hasDownArrow property of the FilteringSelect makes drop down arrow invisible. This can be useful in some situations. For example if you want to represent the data not as drop down list but as a tree. In this case you can set the drop down arrow to invisible, define your own button right to the FilteringSelect and show up a dialog with the tree representation if the user clicks on you custom button. (more…)

Dojo: Function for collapsing dijit.Tree

Friday, March 9th, 2012

dijit.Tree class in dojo does not contain a function to collapse all its nodes automatically. There is a function _collapseNode which collapses one node. We will use it to realize the recursive approach to collapse the whole tree. Important: don’t close the root element, otherwise your whole tree disappears!

function collapsTree(tree) {
   // recursive function for collapsing the nodes
   function collapseRec(node) {
        // the root node should not be collapsed
        if (tree.showRoot == false && tree.rootNode != node) {
            tree._collapseNode(node);
        }
        // get only expandable children
        var children= dojo.filter(node.getChildren() || [], function (node) {
                                       return node.isExpandable;
                          });
       // this is the magic! dojo waits till one node collapses
      // before it processes the next node
       dojo.map(children, collapse);
   }
   if(tree)
      collapseRec(tree.rootNode);
}

DOJO: Refresh/update target URL for dijit.Tree

Wednesday, February 22nd, 2012

Generally, DOJO does not support a direct refresh/update of the dijit.Tree. If you want to provide your dijit.Tree object by a new target URL and refresh your dijit.Tree, there are two possibilities. The first one is to destroy your tree object completely and build up your tree again with a new store (with new target URL). But its not that elegant. The better way is to extend your dijit.Tree class by the underlying function.
(more…)