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
close icon

Showing message in a row when no data in SfGrid

Hi ,
     I am using sfDatagrid to show some data , it's working perfect. But when there is no data it shows empty grid, Instead of this I want to show some message in a first row of grid like "No Records found" when the list of data is empty/null. Please give me solution for my requirement.

Regards.

Attachment: Grid_d773fde8.zip

1 Reply

MK Muthukumar Kalyanasundaram Syncfusion Team April 25, 2017 01:53 AM UTC

Hi Murali, 
 
Thank you for contacting Syncfusion support. 
 
We have analyzed your query. You can achieve your requirement by handling ItemsSourceChanged event. In the event, we have checked with dataGrid.ItemSource as empty or not. If dataGrid.ItemSource as null, then enable the visibility of textblock as shown like below code, 
 
Code Snippet: 
 
this.dataGrid.ItemsSourceChanged += DataGrid_ItemsSourceChanged; 
 
private void DataGrid_ItemsSourceChanged(object sender, GridItemsSourceChangedEventArgs e) 
{ 
    if (dataGrid.View != null && (this.dataGrid.DataContext as UserInfoViewModel).UserDetails.Count != 0) 
    { 
        txtBlock.Visibility = Visibility.Collapsed; 
    } 
    else 
        txtBlock.Visibility = Visibility.Visible; 
} 
 
 
 
Please let us know if you have any query. 
 
Regards, 
Muthukumar K 


Loader.
Live Chat Icon For mobile
Up arrow icon