Index

Classes

Class

Methods

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.

Class Detail
Banana.Controls.DataGridTreeListRender()

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);
Method Detail
addDataSource(source, targetItems, instant)

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
addItem(item)
Parameters:
{Object} item
closeNode(index, datasource)
Parameters:
{int} index
{Object} datasource
createLoadMoreButton(index, limit, nodeData)

creates a load more button

Parameters:
{String} index
{int} limit
nodeData
createNodeInfo(datasource, parentIndex, func)

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
deSelectIndex(index)

calls the deselect method in the item render

Parameters:
{int} index
{Object} getDataSourceByIndex(i)

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}
{Object} getDataSourceByKey(key)

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}
{int} getIndexByDataSource(datasource)
Parameters:
{Array} datasource
Returns:
{int} index
{Object} getNodeData()

gets node data from root

Returns:
{Object}
{Data} getNodeDataByData(ds)
Parameters:
{Object} ds
Returns:
{Data}
{String} getParentIndex(i)
Parameters:
{int} i
Returns:
{String} parent index TODO: we are using this method a lot and it is slow. make it quicker by caching
getRenderedItemRenderByData(data)

return {Banana.Controls.UiControl)

Parameters:
data
{Object} getRenderedItemRenderByIndex(index)

Gets the rendered item render instance by index

Parameters:
index
Returns:
{Object}
{Boolean} hasItemIndexKey(key)

gives true when item is found by given index key use this function to ensure uniquality

Parameters:
key
Returns:
{Boolean}
hideLoaderInNode(index)

hides the loader also sets this.showingLoader to false;

Parameters:
{int} index
nodeClicked(int, true)

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
openNode(index, datasource)
Parameters:
{int} index
{Object} datasource
removeChildDataRecursivly(item)

removes all data from item and children recursivly note this function does not modify gui objects

Parameters:
{Array} item
removeItem(item)
Parameters:
{Object} item
removeNodeByKey(key)

removes node by key key is the {object}[this.indexKey];

Parameters:
{String} key
removeSelectedItems()
removeToggleControl(index, rerender)
Parameters:
{int} index
{Boolean} rerender
restoreSelectedIndices()

TODO selected indices should be saved in nodedata now its seperated

selectAllFromIndex(index, datasource)

Selects all indices from given index.

Parameters:
{String} index
{mixed} datasource
for internal use only
selectIndex(index, preventEvent)

calls the select method in the item render

Parameters:
{int} index
preventEvent
{this} setChildProperty(ck)

Specify which property contain the childs

Parameters:
{String} ck
Returns:
{this}
{this} setChildRequestSizeLimit(limit)

sets child size request limit use this when loading from external resources is needed

Parameters:
{int} limit
Returns:
{this}
setDefaultItemRender(render)
Parameters:
{Banana.Controls.TreeItemRender} render
{this} setDefaultOpen(bool)

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}
{this} setIndexItemRender(index, ir)

sets item render on index

Parameters:
{int} index
{Banana.Controls.TreeItemRender} ir
Returns:
{this}
setItemRenderByIndex(index, render, dontCreate, ignoreDataItemRenderMap)

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
{this} setMaximizeNodeWidth(bool)

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}
setNodeData(nodeData)

Sets node data

Parameters:
{Object} nodeData
setNodeDataByData(data, source)
Parameters:
{Object} data
{Object} source
{this} setSortfunction(sf)

sort function which is used to order nodes per node level

Parameters:
{Object} sf
Returns:
{this}
showLoaderInNode(index)

shows a loader inside a node

Parameters:
{int} index
toLogger(messsage)
Parameters:
{String} messsage

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 05 2012 22:01:42 GMT+0100 (CET)