3 <input jsId='ftree' dojoType="openils.widget.FilteringTreeSelect" searchAttr='shortname' labelAttr='shortname' tree='myTree'/>
7 var tree = new openils.widget.FilteringTreeSelect(null, parentDiv);
8 tree.searchAttr = 'shortname';
9 tree.labelAttr = 'shortname';
10 tree.parentField = 'parent_ou';
11 tree1.tree = fieldmapper.aou.globalOrgTree;
16 if(!dojo._hasResource["openils.widget.FilteringTreeSelect"]){
17 dojo.provide("openils.widget.FilteringTreeSelect");
18 dojo.require("dijit.form.FilteringSelect");
21 "openils.widget.FilteringTreeSelect", [dijit.form.FilteringSelect], {
24 parentField : 'parent',
26 childField : 'children',
29 startup : function() {
30 this.tree = (typeof this.tree == 'string') ?
31 dojox.jsonPath.query(window, '$.' + this.tree, {evalType:"RESULT"}) : this.tree;
33 console.log("openils.widget.FilteringTreeSelect: Tree needed!");
36 if(!dojo.isArray(this.tree)) this.tree = [this.tree];
37 this.className = this.tree[0].classname;
40 dojo.forEach(this.tree, function(node) { self._makeNodeList(node); });
41 if(this.dataList.length > 0) {
42 var storeData = fieldmapper[this.className].initStoreData();
43 storeData.items = this.dataList;
44 this.store = new dojo.data.ItemFileReadStore({data:storeData});
46 this.inherited(arguments);
49 // Compile the tree down to a depth-first list of dojo data items
50 _makeNodeList : function(node, depth) {
52 var storeItem = node.toStoreItem();
53 storeItem._depth = depth++;
54 this.dataList.push(storeItem);
55 for(var i in node[this.childField]())
56 this._makeNodeList(node[this.childField]()[i], depth);
59 // For each item, find the depth at display time by searching up the tree.
60 _getMenuLabelFromItem : function(item) {
63 label: '<div style="padding-left:'+ (item._depth * this.defaultPad) +'px;">' +
64 this.store.getValue(item, this.labelAttr) + '</div>'