3 <div dojoType="openils.widget.FilteringTreeSelect" tree="orgTree" parentField="parent_ou" searchAttr="shortname"/>
4 <div dojoType="openils.widget.FilteringTreeSelect" tree="grpTree"/>
6 The tree attribute is expected to be a tree-shaped pile of OpenSRF objects.
10 if(!dojo._hasResource["openils.widget.FilteringTreeSelect"]){
11 dojo.provide("openils.widget.FilteringTreeSelect");
12 dojo.require("dijit.form.FilteringSelect");
13 dojo.require('dojo.data.ItemFileReadStore');
14 dojo.require('openils.Util');
15 dojo.require("dojox.jsonPath");
18 "openils.widget.FilteringTreeSelect", [dijit.form.ComboBox],
22 childField : 'children',
23 parentField : 'parent',
29 startup : function () {
30 this.labelAttr = '_label'; // force it
31 this.labelType = 'html'; // force it
33 this._tree = (typeof this.tree == 'string') ?
34 dojox.jsonPath.query(window, '$.' + this.tree, {evalType:"RESULT"}) : this.tree;
35 if (!dojo.isArray(this._tree)) this._tree = [ this._tree ];
38 if (!this.valueField) this.valueField = this._tree.Identifier;
41 this._tree.forEach( function (node) { self._add_items( node, 0 ); } );
43 this.store = new dojo.data.ItemFileReadStore({
45 identifier : this.valueField,
46 items : this._datalist
50 this.inherited(arguments);
53 _add_items : function ( node, depth ) {
54 var lpad = this.defaultPad * depth++;
56 var data = node.toStoreItem();
57 data._label = '<div style="padding-left:'+lpad+'px;">' + node[this.searchAttr]() + '</div>';
59 this._datalist.push( data );
61 var kids = node[this.childField]();
63 this._add_items( kids[j], depth );