///
import ezTree = require("./tree");
import ezDataGrid = require("./datagrid");
export interface ITreeGridRow extends ezTree.ITreeNode {
_parentId?: string;
children: ITreeGridRow[];
key: string;
ns?: string;
type?: string;
value?: string;
expandable?: boolean;
}
export interface TreeGridOptions extends ezDataGrid.DataGridCommonOptions {
idField?: string;
treeField?: string;
animate?: boolean;
lines?: boolean;
loader?: (param, success, error) => void;
loadFilter?: (data, parentId) => any;
onClickRow?: (row: ITreeGridRow) => void;
onDblClickRow?: (row: ITreeGridRow) => void;
onClickCell?: (field: string, row: ITreeGridRow) => void;
onDblClickCell?: (field: string, row: ITreeGridRow) => void;
onBeforeLoad?: (row: ITreeGridRow, param) => boolean | void;
onLoadSuccess?: (row: ITreeGridRow, data) => void;
onLoadError?: (args) => void;
onBeforeExpand?: (row: ITreeGridRow) => boolean | void;
onExpand?: (row: ITreeGridRow) => void;
onBeforeCollapse?: (row: ITreeGridRow) => boolean | void;
onCollapse?: (row: ITreeGridRow) => void;
onContextMenu?: (e, row: ITreeGridRow) => void;
onBeforeEdit?: (row: ITreeGridRow) => void;
onAfterEdit?: (row: ITreeGridRow, changes) => void;
onCancelEdit?: (row: ITreeGridRow) => void;
}
export declare class TreeGrid implements ezTree.ITree, ezDataGrid.IDataGrid {
selector: string | JQuery | HTMLElement;
private func;
$tree: JQuery;
constructor(selector: string | JQuery | HTMLElement, options?: TreeGridOptions);
/**
* Return the options of treegrid.
**/
options(): TreeGridOptions;
datagrid(): ezDataGrid.DataGrid;
doCellTip(options: any): this;
cancelCellTip(): this;
/**
* Set treegrid size, the options contains two properties:
width: the new width of treegrid.
height: the new height of treegrid.
**/
resize({width, height}: {
width: any;
height: any;
}): this;
/**
* fix the specified row height.
**/
fixRowHeight(rowId: any): this;
/**
* Load the treegrid data.
**/
loadData(data: any): this;
/**
* Load and show the first page. Available since version 1.3.4.
* Code example:
*
* // load and send some request parameters
* $('#tg').treegrid('load', {
* q: 'abc',
* name: 'name1'
* });
**/
load(param: any): this;
/**
* Reload treegrid data. If the 'id' parameter is passed, reload the specified tree row, otherwise reload all tree rows.
Code example:
$('#tt').treegrid('reload', 2); // reload the row which value is equals to 2
$('#tt').treegrid('reload'); // reload the all rows
$('#tt').treegrid('reload', {id:2, q:'abc'}); // reload the specified row with 'q' parameter passing to server
**/
reload(id?: any): this;
/**
* Reload footer data.
**/
reloadFooter(footer: any): this;
/**
* Get the loaded data.
**/
getData(): any;
/**
* Get the footer data.
**/
getFooterRows(): any;
/**
* Get the root node, return node object
**/
getRoot(): ITreeGridRow;
/**
* Get the root nodes, return node array.
**/
getRoots(): ITreeGridRow[];
/**
* Get the parent node.
**/
getParent(id: string | ITreeGridRow): ITreeGridRow;
/**
* Get the children nodes.
**/
getChildren(id: string): ITreeGridRow[];
/**
* Get the selected node and return it, if no node selected return null.
**/
getSelected(): ITreeGridRow;
/**
* Get all selected nodes.
**/
getSelections(): ITreeGridRow[];
/**
* Get the specified node level.
**/
getLevel(id: string): number;
/**
* Find the specifed node and return the node data.
**/
find(id: string): ITreeGridRow;
/**
* Select a node.
**/
select(id: string): this;
scrollTo(id: string): this;
/**
* Unselect a node.
**/
unselect(id: string): this;
/**
* Select all nodes.
**/
selectAll(): this;
/**
* Unselect all nodes.
**/
unselectAll(): this;
/**
* Collapse a node.
**/
collapse(id: string): this;
/**
* Expand a node.
**/
expand(id: string): this;
/**
* Collapse all nodes.
**/
collapseAll(id: string): this;
expandRecursively(id: string, keepState?: boolean): void;
private isExpandingAll;
/**
* Expand all nodes.
**/
expandAll(id: string, keepState?: boolean): this;
/**
* Expand from root to specified node.
**/
expandTo(id: string): this;
/**
* Toggles expanded/collapsed state of the node.
**/
toggle(id: string): this;
/**
* Append nodes to a parent node. The 'param' parameter contains following properties:
parent: the parent node id, if not assigned, append as root nodes.
data: array, the nodes data.
Code example:
// append some nodes to the selected row
var node = $('#tt').treegrid('getSelected');
$('#tt').treegrid('append',{
parent: node.id, // the node has a 'id' value that defined through 'idField' property
data: [{
id: '073',
name: 'name73'
}]
});
**/
append(params: {
parent?: string;
data: any[];
}): this;
/**
* Insert a new node to specified node. The 'param' parameter contains following properties:
before: the id value of node to insert before.
after: the id value of node to insert after.
data: the new node data.
Available since version 1.3.1.
Code example:
// insert a new node before the selected node
var node = $('#tt').treegrid('getSelected');
if (node){
$('#tt').treegrid('insert', {
before: node.id,
data: {
id: 38,
name: 'name38'
}
});
}
**/
insert(params: {
before?: string;
after?: string;
data: any;
}): this;
/**
* Remove a node and it's children nodes.
**/
remove(id: string): this;
/**
* Remove a node's children nodes. (added by fish, extension method)
**/
/**
* Pop and return a node data including its children after remove that node. Available since version 1.3.1.
**/
pop(id: string): ITreeGridRow;
/**
* Refresh the specified node.
**/
refresh(id: string): this;
/**
* Update the specified node. The param contains following properties:
id: the node id that indicate the node to be updated.
row: the new row data.
Available since version 1.3.1.
Code example:
$('#tt').treegrid('update',{
id: 2,
row: {
name: 'new name',
iconCls: 'icon-save'
}
});
**/
update(param: {
id: string;
row: any;
}): this;
/**
* Begin editing a node.
**/
beginEdit(id: string): this;
/**
* End editing a node.
**/
endEdit(id: string): this;
/**
* Cancel editing a node.
**/
cancelEdit(id: string): this;
/**
* Get the specified row editors. Each editor has the following properties:
actions: the actions that the editor can do.
target: the target editor jQuery object.
field: the field name.
type: the editor type.
**/
getEditors(id: string): any;
/**
* Get the specified editor, the param contains two properties:
id: the row node id.
field: the field name.
**/
getEditor(param: {
id: string;
field: string;
}): any;
/**
* Display the treegrid lines.
**/
showLines(): this;
getRootParent(rowOrId: any): ITreeGridRow | undefined;
rawItem: any;
readonly collectionName: any;
findJQueryRow(rowOrId: any): JQuery;
getRow(rowOrId: any): ITreeGridRow;
getPanel(): JQuery;
getSiblings(row: ITreeGridRow): ITreeGridRow[];
getRowRange(fromRow: ITreeGridRow, toRow: ITreeGridRow): ITreeGridRow[];
showEditedFlag(row: any): this;
sort(param: {
sortName: string;
sortOrder: string;
}): this;
expandWholeTree(withAjaxLoading: any, keepState?: boolean): Promise;
collapseWholeTree(): this;
getColumnFields(frozen?: boolean): any;
/**
* adjusts the column width to fit the contents. Available since version 1.3.
**/
autoSizeColumn(field?: string): this;
scrollAndSelectRow(id: string, parentIds?: string[]): void;
/**
* Create and enable filter functionality. The 'filters' parameter is an array of filter configuration. Each item contains following properties:
* 1) field: the custom rule on.
* 2) type: the filter type, possible values are: label,text,textarea,checkbox,numberbox,validatebox,datebox,combobox,combotree.
* 3) options: the options of the filter type.
* 4) op: the filter operation, possible values are: contains,equal,notequal,beginwith,endwith,less,lessorequal,greater,greaterorequal.
*/
enableFilter(filters?: any): any;
/**
* Disable filter functionality.
*/
disableFilter(): any;
/**
* Destroy the filter bar.
*/
destroyFilter(): any;
/**
* Get the filter rule.
*/
getFilterRule(field: string): any;
/**
* Add a filter rule.
*/
addFilterRule(param: {
field: string;
op?: string;
value?;
}): any;
/**
* Remove a filter rule. If the 'field' parameter is not specified, remove all the filter rules.
*/
removeFilterRule(field?: string): any;
/**
* Do the filter based on some filter rules.
*/
doFilter(): any;
/**
* Get the filter component on a specified field.
*/
getFilterComponent(field: string): any;
/**
* Resize the filter component.
*/
resizeFilter(field: string): any;
}