Skip to main content
All docs
V25.1
  • DxTreeList.GetDataItem(Int32) Method

    Returns a data source item bound to the row with the specified visible index.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public object GetDataItem(
        int visibleIndex
    )

    Parameters

    Name Type Description
    visibleIndex Int32

    The row’s visible index.

    Returns

    Type Description
    Object

    The data item.

    Remarks

    Pass a data item to the GetDataItemValue method to get the item’s field value when the TreeList is bound to a collection of anonymous objects. In other cases, you can cast a data item to the corresponding type and use the {DataItem.FieldName} notation to get the item’s field value.

    Note

    When the TreeList is bound to the GridDevExtremeDataSource or loads data on demand, call the WaitForRemoteSourceRowLoadAsync(Int32) method before you execute the GetDataItem method to ensure that the specified data row is loaded.

    The code snippet below performs the following actions:

    • Obtains a data item bound to the first visible row.
    • Returns the EmployeeName field value for this item.
    <style>
        .my-button {
            width: 250px;
        }
    </style>
    
    <DxTreeList @ref="MyTreeList" Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
        <Columns>
            <DxTreeListDataColumn FieldName="Name" Caption="Task" />
            <DxTreeListDataColumn FieldName="StartDate" />
            <DxTreeListDataColumn FieldName="DueDate" />
        </Columns>
    </DxTreeList>
    <p />
    <DxButton Click="OnGetDataItem" CssClass="my-button" Text="Get Data Item for the First Row" />
    <p />
    @Alert
    
    @code {
        ITreeList MyTreeList { get; set; }
        object TreeListData { get; set; }
        public string Alert { get; set; } = "";
    
        void OnGetDataItem() {
            var fieldValue = MyTreeList.GetDataItemValue(MyTreeList.GetDataItem(0), "EmployeeName");
            Alert = $"The first row's Employee Name is '{fieldValue}'.";
        }
    }
    

    TreeList - Get Data Item

    See Also