Hide "No records to display" text when DataGrid is rendering data

When the Grid is loading data but before its rendering into the gird, the grid displays the text "No records to display" on the first row. The text is replaced once the data is rendered into the grid.
Is is possible to hide this text when we know that we have data that will replace it?

3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team March 4, 2021 10:38 AM UTC

Hi Michael, 

Greetings from Syncfusion support. 

We have support for EmptyRecordTemplate in Grid. Please refer the below documentation for more details regarding this, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 



MA Michael Aston March 5, 2021 10:11 AM UTC

Thanks. I ended up with the following code in OnParametersSet() which implies that this should really be a feature of the Grid component checking against the datasource.

            // Handling issue where the "No records to display" text is visible whilst rendering the data into the grid.
            if (FilteredRecentPinnedList.Count > 0)
                this.RecordsText = TString.value("Loading records");
            else
                this.RecordsText = TString.value("No records to display");


RS Renjith Singh Rajendran Syncfusion Team March 8, 2021 12:17 PM UTC

Hi Michael, 

Greetings from Syncfusion support. 

Based on this scenario, we suggest you to use the Grid’s DataBound event to achieve this requirement. 

Please refer the codes below, 

 
<SfGrid DataSource="@Orders" AllowPaging="true"> 
    <GridEvents DataBound="DataBound" TValue="Order"></GridEvents> 
    <GridTemplates> 
        <EmptyRecordTemplate> 
            <span>@RecordsText</span> 
        </EmptyRecordTemplate> 
    </GridTemplates> 
    ... 
</SfGrid> 
 
    public List<Order> Orders = new List<Order>(); 
    public string RecordsText { getset; } 
    ... 
    public void DataBound()    {       if (Orders.Count > 0)       {          this.RecordsText = "Loading records";       }       else       {          this.RecordsText = "No records to display";       }    }

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 


Marked as answer
Loader.
Up arrow icon