diff --git a/etemplate/inc/class.etemplate_widget_tree.inc.php b/etemplate/inc/class.etemplate_widget_tree.inc.php index fff89f473a..5dedd40c8f 100644 --- a/etemplate/inc/class.etemplate_widget_tree.inc.php +++ b/etemplate/inc/class.etemplate_widget_tree.inc.php @@ -15,6 +15,28 @@ * eTemplate tree widget * * @see /phpgwapi/js/dhtmlxtree/docsExplorer/dhtmlxtree/dhtmlxtree___syntax_templates.html Tree syntax + * + * Example initialisation of tree via $sel_options array: + * + * $sel_options['tree'] = array( + * 'id' => 0, 'item' => array( + * array('id' => '/INBOX', 'text' => 'INBOX', 'tooltip' => 'Your inbox', 'open' => 1, 'im1' => 'kfm_home.png', 'im2' => 'kfm_home.png', 'child' => '1', 'item' => array( + * array('id' => '/INBOX/sub', 'text' => 'sub', 'im0' => 'folderClosed.gif'), + * array('id' => '/INBOX/sub2', 'text' => 'sub2', 'im0' => 'folderClosed.gif'), + * )), + * array('id' => '/user', 'text' => 'user', 'child' => '1', 'item' => array( + * array('id' => '/user/birgit', 'text' => 'birgit', 'im0' => 'folderClosed.gif'), + * )), + * )); + * + * Please note: + * - id of root-item has to be 0, ids of sub-items can be strings or numbers + * - item has to be an array (not json object: numerical keys 0, 1, ...) + * - im0: leaf image (default: leaf.gif), im1: open folder image (default: folderOpen.gif), im2: closed folder (default: folderClosed.gif) + * - for arbitrary image eg. $icon = common::image($app, 'navbar') use following code: + * list(,$icon) = explode($GLOBALS['egw_info']['server']['webserver_url'], $icon); + * $icon = '../../../../..'.$icon; + * - json autoloading uses identical data-structur */ egw_framework::includeCSS('/phpgwapi/js/dhtmlxtree/css/dhtmlXTree.css'); class etemplate_widget_tree extends etemplate_widget diff --git a/etemplate/js/et2_widget_tree.js b/etemplate/js/et2_widget_tree.js index 320210c827..6a407597a2 100644 --- a/etemplate/js/et2_widget_tree.js +++ b/etemplate/js/et2_widget_tree.js @@ -27,6 +27,8 @@ /** * Tree widget * + * For syntax of nodes supplied via sel_optons or autoloading refer to etemplate_widget_tree class. + * * @augments et2_inputWidget */ var et2_tree = et2_inputWidget.extend( @@ -265,8 +267,11 @@ var et2_tree = et2_inputWidget.extend( f(data,f); options = data; } - - this.input.loadJSONObject(options); + // if no options given, but autoloading url, use that to load initial nodes + if (!options.id && this.input.XMLsource) + this.input.loadJSON(this.input.XMLsource); + else + this.input.loadJSONObject(options); }, set_value: function(new_value) {