/// export interface IConnAtrributes { connectionId: string; connConfigId?: string; dataRole: string; db?: string; collection?: string; stats?: any; isGridFS?: boolean; isGridFSChunks?: boolean; roleDb?: string; rs?: string; } export interface ITreeNode { id: string; text: string; iconCls?: string; state?: string; checked?: boolean; attributes: IConnAtrributes; children: ITreeNode[]; items?: ITreeNode[]; target?: any; domId?: string; } export interface TreeOptions { url?: string; method?: string; singleSelect?: boolean; animate?: boolean; checkbox?: boolean; cascadeCheck?: boolean; onlyLeafCheck?: boolean; lines?: boolean; dnd?: boolean; data?: any[]; queryParams?: Object; formatter?: (node: ITreeNode) => string; filter?: (q: string, node: ITreeNode) => boolean; loader?: (param, success, error) => void; loadFilter?: (data, parent) => any; onClick?: (node: ITreeNode) => void; onDblClick?: (node: ITreeNode) => void; onBeforeLoad?: (node: ITreeNode, param) => void; onLoadSuccess?: (node: ITreeNode, data) => void; onLoadError?: (args) => void; onBeforeExpand?: (node: ITreeNode) => void; onExpand?: (node: ITreeNode) => void; onBeforeCollapse?: (node: ITreeNode) => void; onCollapse?: (node: ITreeNode) => void; onBeforeCheck?: (node: ITreeNode, checked) => void; onCheck?: (node: ITreeNode, checked) => void; onBeforeSelect?: (node: ITreeNode) => void; onSelect?: (node: ITreeNode) => void; onContextMenu?: (e, node: ITreeNode) => void; onBeforeDrag?: (node: ITreeNode) => void; onStartDrag?: (node: ITreeNode) => void; onStopDrag?: (node: ITreeNode) => void; onDragEnter?: (target, source) => void; onDragOver?: (target, source) => void; onDragLeave?: (target, source) => void; onBeforeDrop?: (target, source, point) => void; onDrop?: (target, source, point) => void; onBeforeEdit?: (node: ITreeNode) => void; onAfterEdit?: (node: ITreeNode) => void; onCancelEdit?: (node: ITreeNode) => void; } export interface ITree { $tree: JQuery; options(): any; getRoot(): ITreeNode; getRoots(): ITreeNode[]; getParent(target: any): ITreeNode; getChildren(target: any): ITreeNode[]; getSelected(): ITreeNode; find(idOrTarget: any): ITreeNode; select(idOTarget: any): ITree; beginEdit(idOrTarget: any): ITree; endEdit(idOrTarget: any): ITree; cancelEdit(idOrTarget: any): ITree; collapse(target: any): ITree; expand(target: any): ITree; collapseAll(target: any): ITree; expandAll(target: any): ITree; expandTo(target: any): ITree; scrollTo(target: any): ITree; } export declare class Tree implements ITree { selector: string | JQuery | HTMLElement; private func; $tree: JQuery; constructor(selector: string | JQuery | HTMLElement, options?: TreeOptions); /** * Return the options of tree. **/ options(): TreeOptions; /** * Load the tree data. **/ loadData(data: any): this; /** * get the specified node object. **/ getNode(target: HTMLElement): ITreeNode[]; /** * get the specified node data, including its children. **/ getData(target: HTMLElement): ITreeNode; /** * Reload tree data. **/ reload(target: HTMLElement): this; /** * Get the root node, return node object **/ getRoot(): ITreeNode; /** * Get the root nodes, return node array. * May has issue(tested on Connection Tree) **/ getRoots(): ITreeNode[]; /** * Get the parent node. **/ getParent(target: HTMLElement): ITreeNode; /** * Get the children nodes. **/ getChildren(target: HTMLElement): ITreeNode[]; /** * Get the checked nodes. The state available values are: 'checked','unchecked','indeterminate'. If the state is not assigned, return the 'checked' nodes. Code example: var nodes = $('#tt').tree('getChecked'); // get checked nodes var nodes = $('#tt').tree('getChecked', 'unchecked'); // get unchecked nodes var nodes = $('#tt').tree('getChecked', 'indeterminate'); // get indeterminate nodes var nodes = $('#tt').tree('getChecked', ['checked','indeterminate']); // get checked and indeterminate nodes **/ getChecked(state: any): ITreeNode[]; /** * Get the selected node and return it, if no node selected return null. **/ getSelected(): ITreeNode; /** * Determine the specified node is leaf, the target parameter indicate the node DOM object. **/ isLeaf(target: HTMLElement): boolean; /** * Find the specifed node and return the node data. **/ find(id: any): ITreeNode; /** * Select a node. **/ select(target: HTMLElement): this; /** * Set the specified node to checked. **/ check(target: HTMLElement): this; /** * Set the specified node to unchecked. **/ uncheck(target: HTMLElement): this; /** * Collapse a node, the target parameter indicate the node DOM object. **/ collapse(target: HTMLElement): this; /** * Expand a node, the target parameter indicate the node DOM object. When node is closed and has no child nodes, the node id value(named as 'id' parameter) will be sent to server to request child nodes data. **/ expand(target: HTMLElement): this; /** *Collapse all nodes. **/ collapseAll(target: HTMLElement): this; /** * Expand all nodes. **/ expandAll(target: HTMLElement): this; /** * Expand from root to specified node. **/ expandTo(target: HTMLElement): this; /** * Scroll to the specified node. Available since version 1.3.4. **/ scrollTo(target: HTMLElement): this; /** * Append some children nodes to a parent node. param parameter has two properties: parent: DOM object, the parent node to append to, if not assigned, append as root nodes. data: array, the nodes data. Code example: // append some nodes to the selected node var selected = $('#tt').tree('getSelected'); $('#tt').tree('append', { parent: selected.target, data: [{ id: 23, text: 'node23' },{ text: 'node24', state: 'closed', children: [{ text: 'node241' },{ text: 'node242' }] }] }); **/ append(param: { parent: HTMLElement; data: any[]; }, selectFirstItem?: boolean): this; /** * Toggles expanded/collapsed state of the node, the target parameter indicate the node DOM object. **/ toggle(target: HTMLElement): this; /** * Insert a node to before or after specified node. the 'param' parameter contains following properties: before: DOM object, the node to insert before. after: DOM object, the node to insert after. data: object, the node data. The code below shows how to insert a new node before the selected node: var node = $('#tt').tree('getSelected'); if (node){ $('#tt').tree('insert', { before: node.target, data: { id: 21, text: 'node text' } }); } **/ insert(param: { before: HTMLElement; after: HTMLElement; data: any; }): this; /** * Remove a node and it's children nodes, the target parameter indicate the node DOM object. **/ remove(target: HTMLElement): this; /** * Pop a node and it's children nodes, the method is same as remove but return the removed node data. **/ pop(target: HTMLElement): ITreeNode; /** * Update the specified node. The 'param' parameter has following properties: target(DOM object, the node to be updated),id,text,iconCls,checked,etc. Code example: // update the selected node text var node = $('#tt').tree('getSelected'); if (node){ $('#tt').tree('update', { target: node.target, text: 'new text' }); } **/ update(param: { target?: HTMLElement; id?: string; text?: string; iconCls?: string; checked?: boolean; }): this; /** * Enable drag and drop feature. **/ enableDnd(): this; /** * Disable drag and drop feature. **/ disableDnd(): this; /** * Begin editing a node. **/ beginEdit(target: HTMLElement): this; /** * End editing a node. **/ endEdit(target: HTMLElement): this; /** * Cancel editing a node. **/ cancelEdit(target: HTMLElement): this; /** * Do the filter action. Available since version 1.4.2. Code example: $('#tt').tree('doFilter', 'easyui'); $('#tt').tree('doFilter', ''); // clear the filter **/ doFilter(text: string): this; }