Grid inside Tab encounters delay on Tab Selection

Hi,

I used the code sample from https://blazor.syncfusion.com/documentation/datagrid/how-to/render-grid-inside-tab-with-specific-height/ and observed that there's delay in the loading of Grid on Tab Selection. That is, on page load, Grid 1 is selected by default. On selecting Grid 2, it takes 6500ms - 500ms = 6000ms for Grid 2 to be selected and the corresponding Grid to be loaded as seen in the image below.

The delay is lesser (though, still observable) on computers with higher specs, and it gets much worse on computers with lower specs. I've attached the Performance diagram generated by Chrome Devtools:



Seeking your assistance on this matter, thank you!

3 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team July 31, 2020 04:00 AM UTC

Hi Zhi, 

Greetings from Syncfusion. 

We have validated your query with the provided details and we will update the further details within one business day. Until then we appreciate your patience. 

Regards, 
Rahul 



ZY Zhi Yuan August 5, 2020 09:58 AM UTC

Hello Rahul,

Any updates? :) Thank you!


VN Vignesh Natarajan Syncfusion Team August 6, 2020 03:46 PM UTC

Hi Zhi,  

Sorry for the delay in getting back to you.  

Query: “The time difference in 2. & 3. is 7000ms as seen in the image below; the Grid & Tabs take about 7000ms to appear after all the other HTML elements have appeared. 

We have validated the reported query at our end and we are able to reproduce the reported behavior during the initial rendering as well as while switching between the tabs. Issue has occurred due to 75 records bounded to Grid without Paging feature. Compared to Blazor Server, there will some delay in Blazor WASM during certain actions.  

In SfGrid component, we have rendered each and every cell as sub component so that it can be customized and utilized by other controls. Consider the Grid control with 75 records and 5 columns, 75 * 5 = 375 components cells along with Header and Pager component. During the certain action in Grid, calling a StatehasChanged() has to be reflected in all available components. So there will be some time delay during a certain action.  

Performance can be increased by reducing the record count or enabling the Paging feature in Grid . Or if you want to render the Grid without Pager component and improve the performance of Grid. Then we suggest you to bind the datasource for Grid using the Tab events instead of OnInitialized lifecycle. And also while switching between the tabs, kindly remove the data bound to Grid and bound the datasource again to Grid using Tab events.  

Refer the below code example.  

  <SfTab ID="Ej2Tab" LoadOn="ContentLoad.Demand" Width="100%"> 
        <TabEvents Created="OnCreated" Selecting="OnSelecting" Selected="OnSelected"></TabEvents> 
        <TabItems> 
            <TabItem> 
                <ChildContent> 
                    <TabHeader Text="Grid 1"></TabHeader> 
                </ChildContent> 
                <ContentTemplate> 
                    <div style="height400px;width:800px"> 
                        <SfGrid DataSource="@OrderData" Height="100%" Width="100%"> 
                            . . . . . 
                        </SfGrid> 
                    </div> 
                </ContentTemplate> 
            </TabItem> 
            <TabItem> 
                <ChildContent> 
                    <TabHeader Text="Grid 2"></TabHeader> 
                </ChildContent> 
                <ContentTemplate> 
                    <div style="height400px;width:800px"> 
                        <SfGrid DataSource="@EmployeesData" Height="100%" Width="100%"> 
                            . . . . .  
                        </SfGrid> 
                    </div> 
                </ContentTemplate> 
            </TabItem> 
        </TabItems> 
    </SfTab> 
</div> 
 
@code { 
 
    public List<Order> Orders { getset; } 
    public List<Order> OrderData { getset; } 
    public List<EmployeeData> Employees { getset; } 
    public List<EmployeeData> EmployeesData{ getset; } 
    public async Task OnCreated(// will be triggered when tab is created 
    { 
        await Task.Yield(); 
        OrderData = Orders; // update the datasource for first Grid with delay 
    } 
    public async Task OnSelecting(SelectingEventArgs Args// will be triggered before selectign a tab 
    { 
        //empty the Grid Datasource 
        OrderData = null; 
        EmployeesData = null; 
    } 
    public async Task OnSelected(SelectEventArgs Args)// will be triggered when tab is selected  
    { 
        await Task.Yield(); 
        // here udpate the selected tag Grid data.  
        if (Args.SelectedIndex == 0) 
        { 
            OrderData = Orders; 
        } 
        else if (Args.SelectedIndex == 1) 
        { 
            EmployeesData = Employees; 
        } 
    } 
    protected override void OnInitialized() 
    { 
        Orders = Enumerable.Range(1, 75).Select(x => new Order() 
        { 
            OrderID = 1000 + x, 
            CustomerID = (new string[] { "ALFKI""ANANTR""ANTON""BLONP""BOLID" })[new Random().Next(5)], 
            Freight = 2.1 * x, 
            OrderDate = DateTime.Now.AddDays(-x), 
        }).ToList(); 
        Employees = Enumerable.Range(1, 75).Select(x => new EmployeeData() 
        { 
            EmployeeID = x, 
            FirstName = (new string[] { "Nancy""Andrew""Janet""Margaret""Steven" })[new Random().Next(5)], 
            LastName = (new string[] { "Davolio""Fuller""Leveringg""peacock""Smith" })[new Random().Next(5)], 
            Role = (new string[] { "Sales Representative""Sales Representative""Sales Manager""HR Manager""Inside Sales Coordinator" })[new Random().Next(5)], 
            HireDate = DateTime.Now.AddDays(-x), 
        }).ToList(); 
    } 


But we are facing some issues while updating the Grid datasource using the Tab events. We have considered it as bug and fixed the issue internally. The fix will be included in our 2020 Volume 2 Service Pack 1 release which is expected to be rolled out by mid of August 2020. So once that issue is resolved in 2020 Volume 2 Service Pack release, you can bound the data to grid with some delay using Tab events to increase the performance of Grid control.  

Till then we appreciate your patience.    

Regards, 
Vignesh Natarajan

Marked as answer
Loader.
Up arrow icon