We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

TreeGrid Search results not showing children

-- Update --
I found the issue. When I put this command inside the treegrid, EnableCollapseAll = "true" , it caused the undesired behavior. If I remove this, the grid works as expected.

--- Original ---
When doing a search which results in the parent and a child both containing the search criteria, the search results show two rows each showing only the parent. If you click on the expand arrow, the child never appears. For example:

Parent: {Id=1, Name=Charlie, Code=CHAR}
Child:  {Id=2, ParentId=1, Name=Charlie 1, Code=C1}

Search Criteria = char
Tested with  FilterHierarchyMode.Parent, Both, Child, and None.

    < EjsTreeGrid ID="TreeGrid" @ref="TreeGrid" DataSource="@TreeData" IdMapping="OrgUnitId" ParentIdMapping="ParentOrgUnitId" TreeColumnIndex="1"
                 AllowPaging="true" AllowExcelExport="true" AllowFiltering="true" AllowMultiSorting="true" AllowPdfExport="true"
                 AllowReordering="true" AllowResizing="true" AllowRowDragAndDrop="true" AllowSorting="true"
                 EnableAltRow="true" EnableCollapseAll="true" EnableHover="true" ShowColumnMenu="true"
                 Toolbar="@(new List() { "Search" })">

        < TreeGridSearchSettings Operator="Operator.Contains" Fields="@(new string[] { "Code", "Name", "LegalName" })"  HierarchyMode="FilterHierarchyMode.Both">

        < TreeGridEvents TValue="Node" RowSelected="RowSelectHandler" OnRecordDoubleClick="DoubleClicked">
        < TreeGridSelectionSettings Type="Syncfusion.EJ2.Blazor.Grids.SelectionType.Single" Mode="Syncfusion.EJ2.Blazor.Grids.SelectionMode.Row">
< /TreeGridSelectionSettings>
        < TreeGridPageSettings PageSizeMode="PageSizeMode.Root" PageSize="50">
        < TreeGridEditSettings AllowAdding="false" AllowEditing="false" AllowDeleting="false" Mode="Syncfusion.EJ2.Blazor.TreeGrid.EditMode.Row">
< /TreeGridEditSettings>
        < TreeGridFilterSettings Type="Syncfusion.EJ2.Blazor.TreeGrid.FilterType.Menu">
        < TreeGridColumns>
            < TreeGridColumn Field="Code" HeaderText="Code" Width="20">
            < TreeGridColumn Field="Name" HeaderText="Name" Width="40">
            < TreeGridColumn Field="LegalName" HeaderText="Legal Name" Width="40">
            < TreeGridColumn Field="ExternalCode" HeaderText="Ext. Code" Width="20">
        < /TreeGridColumns>
    < /EjsTreeGrid>

This shows the search applied. Search is on Code, Name, and Legal Name fields.  

This shows the tree grid without a search applied: 

5 Replies

SE Sathyanarayanamoorthy Eswararao Syncfusion Team January 22, 2020 12:32 PM UTC

Hi Scott, 

Thanks for using Syncfusion products. 

Query: When doing a search which results in the parent and a child both containing the search criteria, the search results show two rows each showing only the parent. 
We were also able to reproduce the mentioned issue on our side. We have confirmed that the mentioned issue is a bug and have logged the bug report for the same. Thank you for taking the time to report this issue “Searching is not working properly if EnableCollapseAll is set as true” and helping us improve our product. Fix for the issue will be included in our Next Bi-Weekly Nuget release which is expected to be rolled out on or before 5th  February 2020. 

You can track the status of the issue by using the below feedback link   

Note: Kindly login to your account to view the feedback link. 

We appreciate your patience until then. 


MM Maurizio Meloni May 2, 2022 06:12 AM UTC

Hello all,

i found the problem.

The expected value for the ParentIdMapping should be NULL if not have any parents.

I was using a default value of "-1" for every object without parent.. in this way they were not showed inside the tree grid.

now i changed the default value to null and now everythign work.

thank you very much!


MP Manivannan Padmanaban Syncfusion Team May 3, 2022 06:45 AM UTC

Hi Maurizio,

As you mentioned, the ParentIdMapping value of the root node (i.e., the parent record) must be null. Because, according to tree grid architecture the ParentIdMapping null value records were considered as the root node.

Please let us know if you require any additional assistance. We will be happy to assist you.


Manivannan Padmanaban

AT Andy Terbovich April 25, 2023 07:37 PM UTC

Hello, I know this issue is old but ​I am seeing the same error with a TreeGrid running sf 20.4.

I double checked all of my data, and all records have ParentId == NULL for parent rows, and all child records have a ParentId that is an existing value/existing record.

If I remove "EnableCollapseAll="true" as a TreeGrid parameter, then the search works as expected, but I would much prefer my project rec

When I search a project that I know has child projects, I get the following error:

023-04-25T19:36:37.402Z] Error: System.Collections.Generic.KeyNotFoundException: The specified key 'hasChildRecords' does not exist in the ExpandoObject.

   at System.Dynamic.ExpandoObject.System.Collections.Generic.IDictionary<System.String,System.Object>.get_Item(String key)

   at Syncfusion.Blazor.TreeGrid.Internal.ExpandCollapse`1.GetCurrentViewData()

   at Syncfusion.Blazor.TreeGrid.Internal.GridRenderer`1.DataBoundHandler()

   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

   at Syncfusion.Blazor.Grids.SfGrid`1.OnAfterRenderAsync(Boolean firstRender)

   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

PS Pon Selva Jeganathan Syncfusion Team April 28, 2023 04:54 AM UTC

Hi Andy Terbovich,

Query: Script error thrown while searching with EnableCollapseAll property

We checked your query by preparing a sample, but we were unable to replicate the issue at our end.

Please refer to the attached sample,

Still if you are facing issue, please provide the following information.

  1. Complete tree code example details
  2. DataBinding details(whether you are using local data or remote data binding)
  3. Package version details. Exact package version.
  4. If possible, try to reproduce the reported issue in the provided sample or share the reproducible sample.

The requested information will be helpful to proceed further.

Kindly get back to us for further assistance.



Pon selva

Attachment: BlazorApp_1344d684.zip

Live Chat Icon For mobile
Up arrow icon