Class Banana.Controls.DataGridTreeListRender
Extends
Banana.Controls.DataGridBaseListRender.
- Methods borrowed from class Banana.Controls.DataGridBaseListRender:
- addSelectedIndex, applyUid, clearSelectedIndex, clearSelectedIndices, getIndexIsSelected, getObject, getRenderedItemRenders, getSelectedIndices, getSelectedItems, getSelectedKeys, moveSelectedItemsDown, moveSelectedItemsUp, removeAllItems, rerender, selectNextFromList, selectPreviousFromList, setItemIndexKey, setSelectedItems
- Methods borrowed from class Banana.Controls.CustomListControl:
- createControls, setData, setDataSource, setDomData
- Methods borrowed from class Banana.Controls.ListControl:
- dataSetSourceBind, getDataSource, setDataKeyField, setDataValueField
- Methods borrowed from class Banana.Controls.DataControl:
- dataSetBind, getData, unDataSetBind, updateDisplay
- Methods borrowed from class Banana.Controls.Panel:
- getTagName
- Methods borrowed from class Banana.UiControl:
- addControl, addCss, addCssClass, getAttribute, getAttributes, getClientId, getCss, getCssClass, getDimensions, getHtml, getHtmlAttributes, getState, getStyle, getStyleProperty, hasCssClass, registerEvents, removeAttribute, removeCssClass, removeState, setAttribute, setClientId, setCss, setEnabled, setState, setStyle, setVisible, switchCssClass, triggerEvent, unregisterEvents
- Methods borrowed from class Banana.Control:
- applyToChildren, bind, clear, createComponents, findControl, generateUniqueId, getControls, getDomEventTypes, getFirstUiControl, getId, getPage, getParent, getProxy, hasBind, invalidateDisplay, onPreInvalidateContents, onWindowResize, remove, render, setId, setPage, setParent, unbind, unload
Defined in: DataGridTreeListRender.js.
Create a datagrid tree list render. a tree is a consists out of nodes with optional child nodes For each node the list creates a node info object with various node state parameters.
bindable events
- dataSourceChanged
- onRequestChilds
- onItemOpened
- onItemClosed
- onPreCreateItem
- onPostCreateIndex
- onItemMouseClick
- onItemMouseOut
- onItemMouseEnter
- onSelectIndex
- onDeselectIndex
- onItemSelect
example
//make some datasource
var datasource =[];
var s1 = {'name':'s1','children':[]};
var s2 = {'name':'s2','children':[]};
var s3 = {'name':'s3','children':[]};
var s4 = {'name':'s4','children':[]};
var s5 = {'name':'s5','children':[]};
var s6 = {'name':'s6','children':[]};
root.push(s1);
root.push(s2);
root.push(s3);
s1.children.push(s4);
s1.children.push(s5);
s4.children.push(s6);
var list = new Banana.Controls.DataGrid();
var listRender = new Banana.Controls.DataGridDataTreeListRender();
listRender.setChildProperty("children");
listRender.setDefaultOpen(true);
listRender.bind('selectIndex',this.getProxy(function(e,index){
listRender.selectAllFromIndex(index)
}));
listRender.setSortfunction(function(a,b)
{
return a.name.toString().toLowerCase().localeCompare(b.name.toString().toLowerCase())
});
list.setListRender(listRender);
list.setDataSource(datasource);
listRender.bind('dataSourceChanged',this.getProxy(function(){
this.dataChanged = true;
}));
listRender.bind('dataChanged',this.getProxy(function(){
}));
this.addControl(list);
How are we adding new data? Every node in our tree got a nodeinfo object with params. The following params are important for this function
nodeinfo.addedChildren -> children added which are not in the regular child collection nodeinfo.childCount -> the initial child collection child. this is without the nodeinfo.addedChildren
If we add new data with the instant boolean to false we add the children to the nodeinfo.addedChildren array. When we receive new data later we check if children exists in the addedChildren array. If yes we remove it from addedChildren and increment the nodeinfo.childcount. This is useful to determine paging/loadnext buttons If the instant boolean is true we just add the children to the regular children
Note: children are always compared to children in nodeinfo.addedChildren.
use the instant boolean when you know for sure that the addedDatasource consists out of new items use false if there might be children which are already in the list
- Parameters:
- {mixed} source
- to add items on
- {Array} targetItems
- {boolean} instant
- when true we instantly render the new items
creates a load more button
- Parameters:
- {String} index
- {int} limit
- nodeData
inserts recursively info to datasource items. this method should always be called after node modification(s)
- Parameters:
- {object} datasource
- {int} parentIndex
- {Object} func
- function which get applied on every item
We assume we can reach the data. this assumtion is made already in the create controls method
TODO: we are using this method a lot and it is slow. make is quicker by caching but watch out. the index datasource mapping relation is changed a lot also
- Parameters:
- {int} i
- Returns:
- {Object}
always returns a source, when invalid key is given we return the root one
- Parameters:
- key
- Returns:
- {Object}
- Parameters:
- {String} i
- index
- Returns:
- {Banana.Controls.DataGridTreeListHolder}
- Parameters:
- {int} i
- Returns:
- {String} parent index TODO: we are using this method a lot and it is slow. make it quicker by caching
Gets the rendered item render instance by index
- Parameters:
- index
- Returns:
- {Object}
gives true when item is found by given index key use this function to ensure uniquality
- Parameters:
- key
- Returns:
- {Boolean}
hides the loader also sets this.showingLoader to false;
- Parameters:
- {int} index
invoked when node is clicked we open the node or close it if in nodeinfo the property needschilds is true we trigger an event to let the user load another childs
- Parameters:
- {index} int
- {boolean} true
- when node is opened
removes all data from item and children recursivly note this function does not modify gui objects
- Parameters:
- {Array} item
removes node by key key is the {object}[this.indexKey];
- Parameters:
- {String} key
Selects all indices from given index.
- Parameters:
- {String} index
- {mixed} datasource
- for internal use only
calls the select method in the item render
- Parameters:
- {int} index
- preventEvent
Specify which property contain the childs
- Parameters:
- {String} ck
- Returns:
- {this}
sets child size request limit use this when loading from external resources is needed
- Parameters:
- {int} limit
- Returns:
- {this}
By default only the root nodes are opened. if you want to have all nodes opened by default, call this method
- Parameters:
- bool
- Returns:
- {this}
sets item render on index
- Parameters:
- {int} index
- {Banana.Controls.TreeItemRender} ir
- Returns:
- {this}
Use this to change item render on a specific index. By default the list render will rerender the new item render
- Parameters:
- {int} index
- {String} render
- {Boolean} dontCreate
- {Boolean} ignoreDataItemRenderMap
use this method to determine if a node should have auto width (fits the content inside the node) or maximum width (fits the grid container) We compute the width of each node and thus a small performance loss.
- Parameters:
- {boolean} bool
- Returns:
- {this}