Column header in SfDataGrid onlyafter loading

I want to enable Column headers in SfDatGrid only once the grid is loaded,Not before loading/ideally, as shown in the attachment.


Attachment: Capture2_6f8d7b2.zip

1 Reply

AR Arulpriya Ramalingam Syncfusion Team November 19, 2021 03:37 PM UTC

Hi Smit, 
 
Thank you for contacting Syncfusion support. 
 
To hide the header row when records are not loaded in grid, the QueryRowHeight event can be used. In that event, e.Height property can be set to zero to hide the header row. We have created a simple sample to achieve your requirement and please make use of the below code example for further details. 
 
Example code 
 
//Event subscription 
dataGrid.QueryRowHeight += DataGrid_QueryRowHeight; 
 
//Event customization 
private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    if (dataGrid.GetHeaderIndex() == e.RowIndex) 
        if ((dataGrid.View == null || (dataGrid.View != null && dataGrid.View.Records.Count == 0))) 
        { 
            e.Height = 0; 
            e.Handled = true; 
        } 
        else 
        { 
            e.Height = dataGrid.HeaderRowHeight; 
            e.Handled = true; 
        } 
} 
  
 
Please get back to us if you have any other queries. 
 
Regards, 
Arulpriya Ramalingam 


Loader.
Up arrow icon