JavaScript/jQuery TreeList - Overview
Columns represent sets of data values that have the same type. To configure columns, assign an array of objects to the columns property. Each object in it configures a single column. If a column does not need to be customized, this array may include the name of the field that provides data for this column.
jQuery
JavaScript
$(function() { $("#treeListContainer").dxTreeList({ // ... columns: [{ dataField: "Title", caption: "Position" }, { dataField: "FullName", width: 300 }, "CompanyName", "City" ] }); });
Angular
HTML
TypeScript
<dx-tree-list ... > <dxi-column dataField="Title" caption="Position"></dxi-column> <dxi-column dataField="FullName" [width]="300"></dxi-column> <dxi-column dataField="CompanyName"></dxi-column> <dxi-column dataField="City"></dxi-column> </dx-tree-list>
import { DxTreeListModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxTreeListModule ], // ... })
Vue
App.vue
<template> <DxTreeList ... > <DxColumn data-field="Title" caption="Position" /> <DxColumn data-field="FullName" :width="300" /> <DxColumn data-field="CompanyName" /> <DxColumn data-field="City" /> </DxTreeList> </template> <script> import 'devextreme/dist/css/dx.light.css'; import DxTreeList, { DxColumn } from 'devextreme-vue/tree-list'; export default { components: { DxTreeList, DxColumn }, // ... } </script>
React
App.js
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import TreeList, { Column } from 'devextreme-react/tree-list'; export default function App() { return ( <TreeList ... > <Column dataField="Title" caption="Position" /> <Column dataField="FullName" width={300} /> <Column dataField="CompanyName" /> <Column dataField="City" /> </TreeList> ); }
The TreeList generates a column per data field if you do not specify the columns array. You can make minor adjustments to these columns with the customizeColumns function. Use the function's parameter to access the column configurations.
jQuery
JavaScript
$(function() { $("#treeListContainer").dxTreeList({ // ... customizeColumns: function (columns) { columns[0].width = 100; columns[1].width = 210; } }) });
Angular
TypeScript
HTML
import { DxTreeListModule } from "devextreme-angular"; // ... export class AppComponent { customizeColumns (columns) { columns[0].width = 100; columns[1].width = 210; } } @NgModule({ imports: [ // ... DxTreeListModule ], // ... })
<dx-tree-list ... [customizeColumns]="customizeColumns"> </dx-tree-list>
Vue
App.vue
<template> <DxTreeList ... :customize-columns="customizeColumns"> </DxTreeList> </template> <script> import 'devextreme/dist/css/dx.light.css'; import DxTreeList from 'devextreme-vue/tree-list'; export default { components: { DxTreeList }, methods: { customizeColumns(columns) { columns[0].width = 100; columns[1].width = 210; } } } </script>
React
App.js
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import TreeList from 'devextreme-react/tree-list'; const customizeColumns = (columns) => { columns[0].width = 100; columns[1].width = 210; }; export default function App() { return ( <TreeList ... customizeColumns={customizeColumns}> </TreeList> ); }
This topic has outlined the ways to configure columns in the TreeList UI component. For a detailed overview of column features, refer to other topics in this section.
See Also
- Column Types: Data Columns | Band Columns | Lookup Columns | Command Columns
Feedback