some more docu for tree-widget and allow to use autoloading-url for initialisation too

This commit is contained in:
Ralf Becker 2013-05-12 13:09:20 +00:00
parent 8f52e2ca3c
commit 8cebfe3339
2 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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,7 +267,10 @@ var et2_tree = et2_inputWidget.extend(
f(data,f);
options = data;
}
// 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);
},