UNPKG

@progress/kendo-treelist-react-wrapper

Version:

Kendo UI TreeList wrapper for React

68 lines (59 loc) 2.03 kB
--- title: Methods page_title: Methods - TreeList - Kendo UI Wrappers for React description: "Utilize the methods of the Kendo UI TreeList wrapper for React." slug: methods_treelist position: 4 --- # Methods The TreeList exposes a set of methods you can use to modify its behavior upon user interaction. ```jsx-preview class TreeListContainer extends React.Component { constructor(props) { super(props); this.columns = [ { field: "Position" }, { field: "Name" }, ] this.data = [ { id: 1, parentId: null, Name: "Jane Smith", Position: "CEO" }, { id: 2, parentId: 1, Name: "Alex Sells", Position: "EVP Sales" }, { id: 3, parentId: 1, Name: "Bob Price", Position: "EVP Marketing" } ] this.dataSource = new kendo.data.TreeListDataSource({ data: this.data, schema: { model: { id: "id" } } }); } componentDidMount(){ // Get a reference to the kendo.ui.TreeList instance. let treelist = $('[data-role="treelist"]').data("kendoTreeList"); // Use the select method to select the first row and get its data item. treelist.select($(".k-treelist tr:eq(1)")); let dataItem = treelist.dataItem(treelist.select()) console.log(dataItem) } render() { return ( <div> <TreeList height={200} columns={this.columns} dataSource={this.dataSource} selectable={true} /> </div> ); } } ReactDOM.render( <TreeListContainer/>, document.querySelector('my-app') ); ``` ## Suggested Links * [Kendo UI TreeList for jQuery](https://docs.telerik.com/kendo-ui/controls/data-management/treelist/overview) * [API Reference of the TreeList Widget](https://docs.telerik.com/kendo-ui/api/javascript/ui/treelist)