Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxTreeList.GetDataItem(Int32) Method

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

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
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.
Razor
<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