Why are query getting executed twice?

Hi

im using hierachly grid
when expand node grid and add breakpoint  in code 
query execut twice 
  public Query GetOrderQuery(Order value)
    {
      breakpoint//  return new Query().Where("CustomerID", "equal", value.CustomerID);
    }

how to resolve?
thank you

1 Reply 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team September 4, 2020 01:15 PM UTC

Hi ALI, 

Greetings from Syncfusion. 

We have validated your query and the reported behavior at our end. The reported behavior is occurred because the hierarchy grid is rendered in same component. So when you open one of the child grid one by one, it gets called for each row along with previously opened child grid queries. 

You can resolve this reported behavior by rendering the hierarchy grid content as a separate component and pass row data to that component. Find the below code snippet and sample for your reference. 

[Index.razor] 
. . . 
<SfGrid DataSource="@Employees" Height="315px"> 
    <GridTemplates> 
        <DetailTemplate> 
            @{ 
                var employee = (context as EmployeeData); 
                <HierarchyGrid RowData="@employee.EmployeeID"></HierarchyGrid>  //rendered hierarchy grid as a separate compoenent and pass mapping ID to the component 
            } 
        </DetailTemplate> 
    </GridTemplates> 
    <GridColumns> 
        . . . 
    </GridColumns> 
</SfGrid> 
 
. . . 
[HierarchyGrid.razor] 
<SfGrid DataSource="@Orders" Query="@GetOrderQuery()"> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="First Name" Width="110"> </GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerName) HeaderText="Last Name" Width="110"></GridColumn> 
        <GridColumn Field=@nameof(Order.ShipCountry) HeaderText="Title" Width="110"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code { 
    [Parameter] 
    public int? RowData { get; set; } 
    public Query GetOrderQuery() 
    { 
        return new Query().Where("EmployeeID", "equal", RowData); 
    } 
 
    . . . 
} 
 


Please let us know if you have any concerns. 

Regards, 
Rahul 


Marked as answer
Loader.
Up arrow icon