How to determine number of rows in SfTreeGrid after SearchAsync?

I have an SfTreeGrid instance called treeGrid, and I query it using SearchAsync:

treeGrid.SearchAsync(searchText);

How do I then determine how many rows are displayed in treeGrid? My current solution is to use 

DataOperations.PerformSearching first, just to see what the result of the search will be, but I don't like it!

Thanks!

Niels


3 Replies 1 reply marked as answer

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 4, 2022 04:03 PM UTC

Hi Niels, 

Query#:- How do I then determine how many rows are displayed in treeGrid? My current solution is to use  

To achieve this(get searched records), we suggest to use GetCurrentViewRecords method of the TreeGrid. Using ActionComplete event of the TreeGrid(which get trigger on completion of Search action), we can get the searched records  with requestType as Searching as like below:- 

Refer to the code below:- 
<SfTreeGrid IdMapping="TaskId" @ref="TreeGrid" DataSource="@TreeGridData" ParentIdMapping="ParentId" TreeColumnIndex="1" Toolbar="@(new List<string>() { "Search" })"> 
    <TreeGridEvents TValue="BusinessObject" OnActionComplete="ActionCompleteHandler"></TreeGridEvents> 
    <TreeGridColumns> 
        <TreeGridColumn Field="TaskId" HeaderText="Task ID" Width="80" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></TreeGridColumn> 
   .    .   . 
</SfTreeGrid> 
 
@code{ 
    SfTreeGrid<BusinessObject> TreeGrid; 
    public List<BusinessObject> TreeGridData { get; set; } 
    protected override void OnInitialized() 
    { 
        this.TreeGridData = BusinessObject.GetSelfDataSource().ToList(); 
    } 
    public void ActionCompleteHandler(ActionEventArgs<BusinessObject> args) 
    { 
        if (args.RequestType.ToString() == "Searching") 
        { 
           var data = TreeGrid.GetCurrentViewRecords(); 
            // Here you can get the searched records 
        } 
 } 

Documentation links:- 

Please get back to us if you need any further assistance. 

Regards, 
Farveen sulthana T 


Marked as answer

ND Niels Døssing March 8, 2022 05:20 PM UTC

Hi Farveen

Thanks - it works as desired!

Why I did not find that method in the first place is a bit of a mystery to me :-)

Regards,

Niels



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 9, 2022 05:21 PM UTC

Hi Niels, 

Thanks for your update. We are glad to know that your reported problem has been resolved.Please get back to us if you need any further assistance. We are happy to assist you. 

Regards, 
Farveen sulthana T 


Loader.
Up arrow icon