A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://js.devexpress.com/Vue/Documentation/ApiReference/UI_Components/dxTreeList/Methods/ below:

Vue TreeList Methods | Vue Documentation

This section describes methods that you can use to manipulate the TreeList UI component in code.

Adds a new column.

Parameters:

The column's configuration or a data field for which the column should be created.

This method is intended to add columns at runtime. To add columns at design-time, use the columns array.

If stateStoring is enabled, the added column is saved in the UI component's state after the creation.

See Also

Adds an empty data row to the highest hierarchical level and switches it to the editing state.

A Promise that is resolved after a new empty row is added.

Use this method if you want to add an empty row. If you need to add a row with data, do the following:

This method works only when paging.enabled is false or when dataSource.reshapeOnPush is true and remoteOperations is false.

See Also

Adds an empty data row to a specified parent row.

Parameters:

parentId: any

The parent row's ID.

A Promise that is resolved after a new empty row is added.

Shows the load panel.

Parameters:

The text for the load panel to display.

Normally, the load panel is invoked automatically while the UI component is busy rendering or loading data. Additionally, you can invoke it by calling this method. If you call it without the argument, the load panel displays text specified by the loadPanel.text property. To specify the appearance of the load panel, use the loadPanel object. Once invoked from code, the load panel will not hide until you call the endCustomLoading() method.

The load panel invoked from code does not replace the automatically invoked load panel. This circumstance might lead to a situation where the load panel invoked from code suddenly changes its text because it was overridden by the automatically invoked load panel. Therefore, be mindful when invoking the load panel with different text.

See Also

Postpones rendering that can negatively affect performance until the endUpdate() method is called.

The beginUpdate() and endUpdate() methods reduce the number of renders in cases where extra rendering can negatively affect performance.

See Also

Gets a data object with a specific key.

The following code shows how to get a data object whose key is 15.

jQuery
widgetInstance.byKey(15).done(function(dataObject) {
        // process "dataObject"
    }).fail(function(error) {
        // handle error
    });
See Also

Discards changes that a user made to data.

Gets the value of a cell with a specific row index and a data field, column caption or name.

Return Value: any

The cell's value.

Sets a new value to a cell with a specific row index and a data field, column caption or name.

TreeList re-renders the entire row or edit form after the cellValue method changes a cell value. To re-render only the modified cell or form item editor, enable repaintChangesOnly.

Call saveEditData() after this method to save the changes:

jQuery
var treeList = $("#treeListContainer").dxTreeList("instance");
treeList.cellValue(0, "Position", "CEO");
treeList.saveEditData();
Angular
import { ..., ViewChild } from "@angular/core";
import { DxTreeListModule, DxTreeListComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxTreeListComponent, { static: false }) treeList: DxTreeListComponent;
    // Prior to Angular 8
    // @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent;
    updateCell(rowIndex, dataField, value) {
        this.treeList.instance.cellValue(rowIndex, dataField, value);
        this.treeList.instance.saveEditData();
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
Vue
<template>
    <DxTreeList ...
        :ref="treeListRefKey"> 
    </DxTreeList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import { DxTreeList } from 'devextreme-vue/tree-list';

const treeListRefKey = 'my-tree-list';

export default {
    components: {
        DxTreeList
    },
    data() {
        return {
            treeListRefKey
        };
    },
    methods: {
        updateCell(rowIndex, dataField, value) {
            this.treeList.cellValue(rowIndex, dataField, value);
            this.treeList.saveEditData();
        }
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRefKey].instance;
        }
    }
}
</script>
React
import React, { useRef } from 'react';
import 'devextreme/dist/css/dx.light.css';

import TreeList from 'devextreme-react/tree-list';

export default function App() {
    const treeList = useRef(null);
    const updateCell = (rowIndex, dataField, value) => {
        treeList.current.instance().cellValue(rowIndex, dataField, value);
        treeList.current.instance().saveEditData();
    };
    return (
        <TreeList ...
            ref={treeList}>
        </TreeList>
    );
}
See Also

Gets the value of a cell with specific row and column indexes.

Parameters:

The index of the row to which the cell belongs. Refer to Column and Row Indexes for more information.

The visible index of the column to which the cell belongs.

Return Value: any

The cell's value.

Sets a new value to a cell with specific row and column indexes.

Parameters:

The index of the row to which the cell belongs. Refer to Column and Row Indexes for more information.

The visible index of the column to which the cell belongs.

value: any

The cell's new value.

Call saveEditData() after this method to save the changes:

jQuery
var treeList = $("#treeListContainer").dxTreeList("instance");
treeList.cellValue(0, 1, "newValue");
treeList.saveEditData();
Angular
import { ..., ViewChild } from "@angular/core";
import { DxTreeListModule, DxTreeListComponent } from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxTreeListComponent, { static: false }) treeList: DxTreeListComponent;
    // Prior to Angular 8
    // @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent;
    updateCell(rowIndex, columnIndex, value) {
        this.treeList.instance.cellValue(rowIndex, columnIndex, value);
        this.treeList.instance.saveEditData();
    }
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
Vue
<template>
    <DxTreeList ...
        :ref="treeListRefKey"> 
    </DxTreeList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import { DxTreeList } from 'devextreme-vue/tree-list';

const treeListRefKey = 'my-tree-list';

export default {
    components: {
        DxTreeList
    },
    data() {
        return {
            treeListRefKey
        };
    },
    methods: {
        updateCell(rowIndex, columnIndex, value) {
            this.treeList.cellValue(rowIndex, columnIndex, value);
            this.treeList.saveEditData();
        }
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRefKey].instance;
        }
    }
}
</script>
React
import React, { useRef } from 'react';
import 'devextreme/dist/css/dx.light.css';

import TreeList from 'devextreme-react/tree-list';

export default function App() {
    const treeList = useRef(null);
    const updateCell = (rowIndex, columnIndex, value) => {
        treeList.current.instance().cellValue(rowIndex, columnIndex, value);
        treeList.current.instance().saveEditData();
    };
    return (
        <TreeList ...
            ref={treeList}>
        </TreeList>
    );
}
See Also

Clears all filters applied to UI component rows.

Clears all row filters of a specific type.

Clears selection of all rows on all pages.

Clears sorting settings of all columns at once.

Switches the cell being edited back to the normal state. Takes effect only if editing.mode is batch or cell and showEditorAlways is false.

Collapses the currently expanded adaptive detail row (if there is one).

Collapses a row with a specific key.

Gets the data column count. Includes visible and hidden columns, excludes command columns.

Gets all properties of a column with a specific identifier.

Parameters:

The column's index, data field, caption, type, or unique name.

This method gets the properties of the first column found by either of the below:

See Also

Gets the value of a single column property.

Parameters:

The column's index, data field, caption, type, or unique name. Refer to columnOption(id) for details.

The property's name.

Return Value: any

The property's value.

Updates the value of a single column property.

Parameters:

The column's index, data field, caption, type, or unique name. Refer to columnOption(id) for details.

The property's name.

optionValue: any

The property's new value.

Updates the values of several column properties.

Parameters:

The column's index, data field, caption, type, or unique name. Refer to columnOption(id) for details.

The properties with their new values.

Specifies the device-dependent default configuration properties for this component.

Parameters:

The component's default device properties.

Object structure:

Name Type Description device

Device

|

Function

Device parameters.
When you specify a function, get information about the current device from the argument. Return true if the properties should be applied to the device.

options

Object

Options to be applied.

defaultOptions is a static method that the UI component class supports. The following code demonstrates how to specify default properties for all instances of the TreeList UI component in an application executed on the desktop.

jQuery
DevExpress.ui.dxTreeList.defaultOptions({ 
    device: { deviceType: "desktop" },
    options: {
        // Here go the TreeList properties
    }
});
Angular
import TreeList, { Properties } from "devextreme/ui/tree_list";
// ...
export class AppComponent {
    constructor () {
        TreeList.defaultOptions<Properties>({
            device: { deviceType: "desktop" },
            options: {
                // Here go the TreeList properties
            }
        });
    }
}
Vue
<template>
    <div>
        <DxTreeList id="treeList1" />
        <DxTreeList id="treeList2" />
    </div>
</template>
<script>
import DxTreeList from "devextreme-vue/tree-list";
import TreeList from "devextreme/ui/tree_list";

TreeList.defaultOptions({
    device: { deviceType: "desktop" },
    options: {
        // Here go the TreeList properties
    }
});

export default {
    components: {
        DxTreeList
    }
}
</script>
React
import dxTreeList from "devextreme/ui/tree_list";
import TreeList from "devextreme-react/tree-list";

dxTreeList.defaultOptions({
    device: { deviceType: "desktop" },
    options: {
        // Here go the TreeList properties
    }
});

export default function App() {
    return (
        <div>
            <TreeList id="treeList1" />
            <TreeList id="treeList2" />
        </div>
    )
}

You can also set rules for multiple device types:

jQuery
const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    DevExpress.ui.dxTreeList.defaultOptions({ 
        device: deviceConfig,
        options: {
            // Here go the TreeList properties
        }
    });
});
Angular
import TreeList, { Properties } from "devextreme/ui/tree_list";
// ...
export class AppComponent {
    constructor () {
        const devicesConfig = [
            { deviceType: 'desktop' },
            { deviceType: 'tablet' },
            { deviceType: 'phone' },
        ];

        devicesConfig.forEach(deviceConfig => {
            TreeList.defaultOptions<Properties>({
                device: deviceConfig,
                options: {
                    // Here go the TreeList properties
                }
            });
        });
    }
}
Vue
<template>
    <div>
        <DxTreeList />
    </div>
</template>
<script>
import DxTreeList from "devextreme-vue/tree-list";
import TreeList from "devextreme/ui/tree_list";

const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    TreeList.defaultOptions({
        device: deviceConfig,
        options: {
            // Here go the TreeList properties
        }
    });
});

export default {
    components: {
        DxTreeList
    }
}
</script>
React
import dxTreeList from "devextreme/ui/tree_list";
import TreeList from "devextreme-react/tree-list";

const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    dxTreeList.defaultOptions({
        device: deviceConfig,
        options: {
            // Here go the TreeList properties
        }
    });
});

export default function App() {
    return (
        <div>
            <TreeList />
        </div>
    )
}

Removes a column.

Parameters:

The column's index, data field, caption or unique name.

Removes a row with a specific index.

View Demo

You cannot call this method to delete a row if this row is being edited in row or form editing mode. In these modes, you can modify only one row at a time and you should finish the row edit to call this method.

See Also

Clears the selection of all rows on all pages or the currently rendered page only.

Cancels the selection of rows with specific keys.

Disposes of all the resources allocated to the TreeList instance.

jQuery

After calling this method, remove the DOM element associated with the UI component:

$("#myTreeList").dxTreeList("dispose");
$("#myTreeList").remove();
Angular

Use conditional rendering instead of this method:

<dx-tree-list ...
    *ngIf="condition">
</dx-tree-list>
Vue

Use conditional rendering instead of this method:

<template>
    <DxTreeList ...
        v-if="condition">
    </DxTreeList>
</template>

<script>
import DxTreeList from 'devextreme-vue/tree-list';

export default {
    components: {
        DxTreeList
    }
}
</script>
React

Use conditional rendering instead of this method:

import React from 'react';

import TreeList from 'devextreme-react/tree-list';

function DxTreeList(props) {
    if (!props.shouldRender) {
        return null;
    }

    return (
        <TreeList ... >    
        </TreeList>
    );
}

class App extends React.Component {
    render() {
        return (
            <DxTreeList shouldRender="condition" />
        );
    }
}
export default App;

Switches a cell with a specific row index and a data field to the editing state. Takes effect only if the editing mode is "batch" or "cell".

Parameters:

The index of the row to which the cell belongs. Refer to Column and Row Indexes for more information.

The name of the data field in the data source.

Switches a cell with specific row and column indexes to the editing state. Takes effect only if the editing mode is "batch" or "cell".

Parameters:

The index of the row to which the cell belongs. Refer to Column and Row Indexes for more information.

The visible index of the column to which the cell belongs.

Switches a row with a specific index to the editing state. Takes effect only if the editing mode is "row", "popup" or "form".

Gets the root UI component element.

Hides the load panel.

Normally, the UI component hides the load panel automatically once data is ready. But if you have invoked the load panel from code using the beginCustomLoading(messageText) method, you must call the endCustomLoading() method to hide it.

See Also

Refreshes the UI component after a call of the beginUpdate() method.

The beginUpdate() and endUpdate() methods reduce the number of renders in cases where extra rendering can negatively affect performance.

See Also

Expands an adaptive detail row.

Parameters:

key: any

The key of the data row to which the adaptive detail row belongs.

Expands a row with a specific key.

Gets a filter expression applied to the UI component's data source using the filter(filterExpr) method and the DataSource's filter property.

Sets focus on the UI component.

Sets focus on a specific cell.

Performs a pre-order tree traversal, executing a function on each visited node. Starts traversing from the top level nodes.

Parameters:

A function to be executed; return false to stop traversing deeper.

Performs a pre-order tree traversal, executing a function on each visited node. Starts traversing from the specified nodes.

Parameters:

Nodes from which to start the traversal.

A function to be executed; return false to stop traversing deeper.

Gets a cell with a specific row index and a data field, column caption or name.

The cell's container. It is an HTML Element or a jQuery Element when you use jQuery.

If the specified row or data field does not exist, the method returns undefined.

Gets a cell with specific row and column indexes.

Parameters:

The index of the row to which the cell belongs. Refer to Column and Row Indexes for more information.

The visible index of the column to which the cell belongs.

The cell's container. It is an HTML Element or a jQuery Element when you use jQuery.

If the specified row or column does not exist, the method returns undefined.

Gets the total filter that combines all the filters applied.

Gets the total filter that combines all the filters applied.

Parameters:

Specifies whether the total filter should contain data fields instead of getters.

Use this method to get the total filter that combines filters applied using filtering UI elements and the filter(filterExpr) method. getCombinedFilter(returnDataField) can return a filter expression that uses data fields instead of getters if you pass true to the returnDataField parameter. If you implement getters like columns[].calculateCellValue in your DataGrid, set returnDataField to false or utilize the getCombinedFilter() method.

For details on how to obtain all filtered and sorted rows of a DataGrid component with getCombinedFilter(returnDataField), refer to the following example:

View on GitHub

For details on how to filter a Chart component's series based on a DataGrid component's filters with getCombinedFilter(returnDataField), refer to the following example:

View on GitHub

See Also

Gets the instance of a UI component found using its DOM node.

Parameters:

The UI component's container.

The UI component's instance.

getInstance is a static method that the UI component class supports. The following code demonstrates how to get the TreeList instance found in an element with the myTreeList ID:

// Modular approach
import TreeList from "devextreme/ui/tree_list";
...
let element = document.getElementById("myTreeList");
let instance = TreeList.getInstance(element) as TreeList;

// Non-modular approach
let element = document.getElementById("myTreeList");
let instance = DevExpress.ui.dxTreeList.getInstance(element);
See Also

Gets the key of a row with a specific index.

Return Value: any

The row's key; undefined if nothing found.

Gets a node with a specific key.

The Node object; undefined if nothing found.

Gets the container of a row with a specific index.

Gets the index of a row with a specific key.

Gets the instance of the UI component's scrollable part.

The scrollable part's instance.

For information on API members of the scrollable part, refer to the ScrollView section. The list below shows ScrollView members that are unavailable for this method.

Properties:

Methods:

See Also

Gets the keys of the rows selected explicitly via the API or via a click or tap.

Keys of selected rows. The keys are stored in the order the user selects rows.

Gets selected row keys.

Parameters:

"all", "excludeRecursive", or "leavesOnly".

Selected row keys. Keys are stored in the order users select rows.

Below is an example of a TreeList with several selected rows:

The getSelectedRowKeys(mode) method called for this TreeList returns different results depending on the mode argument:

If remote operations are enabled, getSelectedRowKeys retrieves selection from currently loaded rows only.

See Also

Gets the data objects of the rows selected explicitly via the API or via a click or tap.

The selected rows' data objects.
The objects are not processed by the DataSource and have the same order in which the rows were selected.

jQuery
var treeList = $("#treeListContainer").dxTreeList("instance");

var selectedRowsData = treeList.getSelectedRowsData();
Angular
import { Component, ViewChild } from '@angular/core';
import { DxTreeListComponent } from 'devextreme-angular';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    @ViewChild('treeListRef', { static: false }) treeList: DxTreeListComponent;
    // Prior to Angular 8
    // @ViewChild('treeListRef') treeList: DxTreeListComponent;

    selectedRowsData = [];

    getSelectedData() {
        this.selectedRowsData = this.treeList.instance.getSelectedRowsData();
    }
}
<dx-tree-list ...
    #treeListRef
></dx-tree-list>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxTreeListModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxTreeListModule
    ],
    providers: [ ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
<template>
    <DxTreeList ...
        :ref="treeListRef">
    </DxTreeList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxTreeList from 'devextreme-vue/tree-list';

const treeListRef = 'treeList';

export default {
    components: {
        DxTreeList
    },
    data() {
        return {
            treeListRef,
            selectedRowsData: []
        }
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRef].instance;
        }
    },
    methods: {
        getSelectedData() {
            this.selectedRowsData = this.treeList.getSelectedRowsData();
        }
    }
}
</script>
React
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import TreeList from 'devextreme-react/tree-list';

class App extends React.Component {
    constructor(props) {
        super(props);

        this.treeListRef = React.createRef();

        this.selectedRowsData = [];

        this.getSelectedData = () => {
            this.selectedRowsData = this.treeList.getSelectedRowsData();
        }
    }

    get treeList() {
        return this.treeListRef.current.instance();
    }

    render() {
        return (
            <TreeList ...
                ref={this.treeListRef}>
            </TreeList>
        );
    }
}
export default App;
ASP.NET MVC Controls
@(Html.DevExtreme().TreeList()
    .ID("treeList")
    @* ... *@
)

<script type="text/javascript">
    function getSelectedData() {
        var treeList = $("#treeList").dxTreeList("instance");
        var selectedRowsData = treeList.getSelectedRowsData();
        // ...
    }
</script>
Calculated values

cannot be obtained because this method gets data objects from the data source.

See Also

Gets selected row data objects.

Parameters:

"all", "excludeRecursive", or "leavesOnly".

Selected row data objects.
The objects are not processed by the DataSource and have the same order in which the rows were selected.

Below is an example of a TreeList with several selected rows:

The getSelectedRowsData(mode) method called for this TreeList returns different results depending on the mode argument:

jQuery
var treeList = $("#treeListContainer").dxTreeList("instance");

var selectedRowsData = treeList.getSelectedRowsData("leavesOnly");
Angular
import { Component, ViewChild } from '@angular/core';
import { DxTreeListComponent } from 'devextreme-angular';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    @ViewChild('treeListRef', { static: false }) treeList: DxTreeListComponent;
    // Prior to Angular 8
    // @ViewChild('treeListRef') treeList: DxTreeListComponent;

    selectedRowsData = [];

    getSelectedData() {
        this.selectedRowsData = this.treeList.instance.getSelectedRowsData('leavesOnly');
    }
}
<dx-tree-list ...
    #treeListRef
></dx-tree-list>
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxTreeListModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxTreeListModule
    ],
    providers: [ ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
<template>
    <DxTreeList ...
        :ref="treeListRef">
    </DxTreeList>
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxTreeList from 'devextreme-vue/tree-list';

const treeListRef = 'treeList';

export default {
    components: {
        DxTreeList
    },
    data() {
        return {
            treeListRef,
            selectedRowsData: []
        }
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRef].instance;
        }
    },
    methods: {
        getSelectedData() {
            this.selectedRowsData = this.treeList.getSelectedRowsData('leavesOnly');
        }
    }
}
</script>
React
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import TreeList from 'devextreme-react/tree-list';

class App extends React.Component {
    constructor(props) {
        super(props);

        this.treeListRef = React.createRef();

        this.selectedRowsData = [];

        this.getSelectedData = () => {
            this.selectedRowsData = this.treeList.getSelectedRowsData('leavesOnly');
        }
    }

    get treeList() {
        return this.treeListRef.current.instance();
    }

    render() {
        return (
            <TreeList ...
                ref={this.treeListRef}>
            </TreeList>
        );
    }
}
export default App;
ASP.NET MVC Controls
@(Html.DevExtreme().TreeList()
    .ID("treeList")
    @* ... *@
)

<script type="text/javascript">
    function getSelectedData() {
        var treeList = $("#treeList").dxTreeList("instance");
        var selectedRowsData = treeList.getSelectedRowsData();
        // ...
    }
</script>

View Demo

See Also

Gets the index of a visible column.

Parameters:

The column's index, data field, caption, type, or unique name. Refer to columnOption(id) for details.

Gets all visible columns.

Visible columns; may include command columns.

Gets all visible columns at a specific hierarchical level of column headers. Use it to access banded columns.

Parameters:

The column headers' level.

Visible columns; may include command columns.

Gets currently rendered rows.

Checks whether the UI component has unsaved changes.

true if the UI component has unsaved changes; otherwise - false.

Gets the UI component's instance. Use it to access other methods of the UI component.

This UI component's instance.

Checks whether an adaptive detail row is expanded or collapsed.

Parameters:

key: any

The key of the data row to which the adaptive detail row belongs.

true if the adaptive detail row is expanded; false if collapsed.

Checks whether a row is expanded or collapsed.

true if the row is expanded; false if collapsed.

Checks whether a row with a specific key is focused.

true if the row is focused; otherwise false.

Checks whether a row with a specific key is selected.

true if the row is selected; otherwise false.

Gets a data object's key.

Return Value: any

The data object's key.

Loads all root node descendants (all data items). Takes effect only if data has the plain structure and remoteOperations.filtering is true.

Loads a specific node's descendants. Takes effect only if data has the plain structure and remoteOperations.filtering is true.

Loads all or only direct descendants of specific nodes. Takes effect only if data has the plain structure and remoteOperations.filtering is true.

Parameters:

Node keys.

Pass true to load only children, false to load all the specified node's descendants.
false by default.

Navigates to a row with the specified key.

A Promise that is resolved after the grid is navigated to the specified row. It is a native Promise or a jQuery.Promise when you use jQuery.

This method performs the following actions:

  1. Switches the UI component to the data page that contains the specified row.
  2. Expands groups in which the row is nested.
  3. Scrolls the UI component to display the row (if the row is outside the viewport).

The following requirements apply when you use this method:

If you enable the remoteOperations property, the TreeList generates additional requests with comparison operators (for example, < and >) to calculate the page number where a row with a focused key is located. This logic does not work if ODataStore is bound to a table with GUID keys. You need to set the autoNavigateToFocusedRow property to false or disable the remoteOperations property to ensure it operates correctly.

See Also

Detaches all event handlers from a single event.

The object for which this method is called.

Detaches a particular event handler from a single event.

Parameters:

The event's name.

The event's handler.

The object for which this method is called.

Subscribes to an event.

Parameters:

The event's name.

The event's handler.

The object for which this method is called.

Use this method to subscribe to one of the events listed in the Events section.

See Also

Subscribes to events.

Parameters:

Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}

The object for which this method is called.

Use this method to subscribe to several events with one method call. Available events are listed in the Events section.

See Also

Gets the value of a single property.

Parameters:

The property's name or full path.

Return Value: any

This property's value.

Updates the value of a single property.

Parameters:

The property's name or full path.

optionValue: any

This property's new value.

Updates the values of several properties.

Parameters:

Options with their new values.

Gets the total page count.

Gets the current page index.

When the scrolling mode is "virtual", this method returns the index of the page whose row is shown first in the UI component.

See Also

Switches the UI component to a specific page using a zero-based index.

Parameters:

The zero-based page index.

Reloads data and repaints data rows.

refresh() calls dataSource.reload() and refreshes component properties such as selection and lookup column dataSources. This method also repaints all data rows if repaintChangesOnly is false (default).

TreeList cannot track data source changes applied outside of the component. To update the component in such cases, call the refresh() method.

The following code snippet shows how to call refresh():

jQuery
var treeList = $("#treeListContainer").dxTreeList("instance");
treeList.refresh()
    .done(function() {
        // ...
    })
    .fail(function(error) {
        // ...
    });
Angular
<dx-tree-list #treeListVar ... >
    <!-- ... -->
</dx-tree-list>
import { Component, ViewChild } from '@angular/core';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    @ViewChild('treeListVar', { static: false }) treeList: DxTreeListComponent;
    // Prior to Angular 8
    // @ViewChild('treeListVar') treeList: DxTreeListComponent;

    refreshTreeList() {
        this.treeList.instance.refresh()
            .then(function() {
                // ...
            })
            .catch(function(error) {
                // ...
            });
    }
}
Vue
<template>
    <DxTreeList ...
        :ref="treeListRefKey">
        <!-- ... -->
    </DxTreeList>
</template>
<script>
import 'devextreme/dist/css/dx.light.css';

import { DxTreeList, /* ... */ } from 'devextreme-vue/tree-list';

const treeListRefKey = 'my-tree-list';

export default {
    components: {
        DxTreeList,
        // ...
    },
    data() {
        return {
            treeListRefKey
        };
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRefKey].instance;
        }
    },
    methods: {
        refreshTreeList() {
            this.treeList.refresh()
                .then(function() {
                    // ...
                })
                .catch(function(error) {
                    // ...
                });
        }
    }
};
</script>
React
import React from 'react';

import 'devextreme/dist/css/dx.light.css';

import { TreeList, /* ... */ } from 'devextreme-react/tree-list';

class App extends React.Component {
    render() {
        return (
            <TreeList ...
                ref={ref => this.treeList = ref}>
                {/* ... */}
            </TreeList>
        );
    }
    refreshTreeList() {
        this.treeList.instance.refresh()
            .then(function() {
                // ...
            })
            .catch(function(error) {
                // ...
            });
    }
}
export default App;
ASP.NET MVC Controls
@(Html.DevExtreme().TreeList()
    .ID("treeListContainer")
    // ...
)
<script type="text/javascript">
    function refreshTreeList() {
        var treeList = $("#treeListContainer").dxTreeList("instance");
        treeList.refresh()
            .done(function() {
                // ...
            })
            .fail(function(error) {
                // ...
            });
    }
</script>
See Also

Reloads data and repaints all or only updated data rows.

Parameters:

Pass true to repaint updated data rows; false to repaint all data rows.

Renders the component again without reloading data. Use the method to update the component's markup and appearance dynamically.

Repaints specific rows.

This method updates the row objects and their visual representation.

See Also

Resets a property to its default value.

Saves changes that a user made to data.

Seeks a search string in the columns whose allowSearch property is true.

Parameters:

A search string. Pass an empty string to clear search results.

Selects rows with specific keys.

Parameters:

The row keys.

Specifies whether previously selected rows should stay selected.

By default, this method call clears selection of previously selected rows. To keep these rows selected, call this method with true as the second argument.

widgetInstance.selectRows([5, 10, 12], true);

If you specify DataGrid's key as composite (for example, key: ['id', 'name']), you need to call this method as follows:

widgetInstance.selectRows([ { id: 5, name: 'Alex' }, { id: 10: name: 'Bob' } ], true);

View Demo

See Also

Selects rows with specific indexes.

View Demo

This method has the following specifics:

See Also

Shows the column chooser.

If the following conditions are met:

Then, column chooser may not update data. To fix this issue, assign true to the columnChooser.enabled property. If you still want to hide the default column chooser icon, use the toolbar option.

See Also

Gets the current UI component state.

The current UI component state.

The following example shows how to save the UI component state in the local storage and load it from there:

jQuery
$(function () {
    const treeList = $("#treeListContainer").dxTreeList({ 
        // ...
    }).dxTreeList("instance");
    $("#save").dxButton({
        text: "Save State",
        onClick: function() {
            const state = treeList.state();
            // Saves the state in the local storage
            localStorage.setItem("treeListState", JSON.stringify(state));
        }
    });
    $("#load").dxButton({
        text: "Load State",
        onClick: function() {
            const state = JSON.parse(localStorage.getItem("treeListState"));
            treeList.state(state);
        }
    });
});
Angular
import { Component, ViewChild } from "@angular/core";
import { 
    DxTreeListModule, 
    DxButtonModule, 
    DxTreeListComponent 
} from "devextreme-angular";
// ...
export class AppComponent {
    @ViewChild(DxTreeListComponent, { static: false }) treeList: DxTreeListComponent
    // Prior to Angular 8
    // @ViewChild(DxTreeListComponent) treeList: DxTreeListComponent
    saveState() {
        const state = this.treeList.instance.state();
        // Saves the state in the local storage
        localStorage.setItem("treeListState", JSON.stringify(state));
    }
    loadState() {
        const state = JSON.parse(localStorage.getItem("treeListState"));
        this.treeList.instance.state(state);
    }
}
@NgModule({
    imports: [
        DxTreeListModule,
        DxButtonModule,
        // ...
    ],
    // ...
})
<dx-tree-list ...>
</dx-tree-list>
<dx-button
    text="Save State"
    (onClick)="saveState()">
</dx-button>
<dx-button
    text="Load State"
    (onClick)="loadState()">
</dx-button>
Vue
<template>
    <DxTreeList ...
        :ref="treeListRefKey">
    </DxTreeList>
    <DxButton
        text="Save State"
        @click="saveState"
    />
    <DxButton
        text="Load State"
        @click="loadState"
    />
</template>

<script>
import 'devextreme/dist/css/dx.light.css';

import DxTreeList, {
    // ...
} from 'devextreme-vue/tree-list';
import DxButton from 'devextreme-vue/button';

const treeListRefKey = "my-tree-list";

export default {
    components: {
        DxTreeList,
        // ...
        DxButton
    },
    data() {
        return {
            treeListRefKey
        }
    },
    methods: {
        saveState() {
            const state = this.treeList.state();
            // Saves the state in the local storage
            localStorage.setItem("treeListState", JSON.stringify(state));
        },
        loadState() {
            const state = JSON.parse(localStorage.getItem("treeListState"));
            this.treeList.state(state);
        }
    },
    computed: {
        treeList: function() {
            return this.$refs[treeListRefKey].instance;
        }
    }
}
</script>
React
import React, { useRef } from 'react';
import 'devextreme/dist/css/dx.light.css';

import TreeList, {
    // ...
} from 'devextreme-react/tree-list';
import Button from 'devextreme-react/button';

export default function App() {
    const treeList = useRef(null);
    const saveState = () => {
        const state = treeList.current.instance().state();
        // Saves the state in the local storage
        localStorage.setItem("treeListState", JSON.stringify(state));
    };
    const loadState = () => {
        const state = JSON.parse(localStorage.getItem("treeListState"));
        treeList.current.instance().state(state);
    };
    return (
        <React.Fragment>
            <TreeList ...
                ref={treeList}>
            </TreeList>
            <Button
                text="Save State"
                onClick={saveState}
            />
            <Button
                text="Load State"
                onClick={loadState}
            />
        </React.Fragment>
    );
}
See Also

Sets the UI component state.

Parameters:

The UI component's state to be set. The state object will override the current state.

After the state is set, the TreeList reloads data to apply sorting, filtering, and other data processing settings.

Refer to the state() method description for an example of how to work with the UI component state.

View Demo

See Also

Updates the UI component's content after resizing.

Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4