i want to show the "No Record found" Message when there is no record exists in RadGridView.
I did some R&D , But did not get any success.
Also, i tried to find the Empty Data Template but didn't get any success.
Please give me solution or Attach a Sample Project ASAP.
i am really oblige to you.
13 Answers, 1 is accepted
Please take a look at this blog post for a reference. Let me know in case you have any difficulties implementing this approach into your application.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I have implemented the same and get the error in "EmptyDataTemplateBehavior" class, when compile the project and the error is:
Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<System.Windows.Controls.Grid>' in EmptyDataTemplateBehavior.cs
Please give a solution for the same.
Thanks
Please use FirstOrDefault() method in this case instead of index.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Appreciate your effort!!
Am done wht u say in prev reply for displying empty data..
Am getting same error in this line.
Grid rootGrid = gridView.ChildrenOfType<Grid>()[0];
Its showing same error above mentioned.
Am stucked.
pls help me
Could you try the approach mentioned above calling FirstOrDefault() method instead of using an index ? Did you get the same exception ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
here is my code.
Pls help me.
private void LoadTemplateIntoGridView()
{
_contentPresenter.IsHitTestVisible = false;
_contentPresenter.DataContext = this;
_contentPresenter.ContentTemplate = EmptyDataTemplate;
Grid rootGrid = _grid.ChildrenOfType<Grid>()[0];
_contentPresenter.SetValue(Grid.RowProperty, 2);
_contentPresenter.SetValue(Grid.RowSpanProperty, 2);
_contentPresenter.SetValue(Grid.ColumnSpanProperty, 2);
_contentPresenter.SetValue(Border.MarginProperty, new Thickness(0, 27, 0, 0));
rootGrid.Children.Add(_contentPresenter);
}
Error 1 Cannot apply indexing with [] to an expression of type 'System.Collections.Generic.IEnumerable<System.Windows.Controls.Grid>'
where i have no do modifications.
thanks in advance
i got it.
thanks a lot for posting such a good post. :)
You can get the root grid as:
//Option 1:
Grid rootGrid = _grid.ChildrenOfType<
Grid
>().FirstOrDefault();
//Option 2:
Grid rootGrid = _grid.ChildrenOfType<
Grid
>().ElementAt(0);
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
i that am taken 4 tabs.
for 4 tabs i want to display the same scenario No data found IT.
But am getting only for one grid only.
pls help me..
You can try attaching the behavior from the blog post for each grid you want to have that functionality.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Am added this behavior to each grid.
but am not getting for others.
am getting for first grid only.
Am also taken one same behaviour class and rename it as behaviour1.cs.
Am added the name space for behaviour1.cs file also.
still not getting.Here is sample code am sending with two behaviours.
am writed same behaviour.cs file for anothere grid also , but am getting that one also for 1 grid only.
Pls help me.
<i:Interaction.Behaviors>
<app:EmptyDataTemplateBehavior>
<app:EmptyDataTemplateBehavior.EmptyDataTemplate>
<DataTemplate>
<TextBlock Text="No Data Found." Foreground="Gray" HorizontalAlignment="Center" FontWeight="Bold" VerticalAlignment="Center" />
</DataTemplate>
</app:EmptyDataTemplateBehavior.EmptyDataTemplate>
</app:EmptyDataTemplateBehavior>
</i:Interaction.Behaviors>
<i1:Interaction.Behaviors>
<app1:EmptyDataTemplateBehavior1>
<app1:EmptyDataTemplateBehavior1.EmptyDataTemplate>
<DataTemplate>
<TextBlock Text="No Data Found." Foreground="Gray" HorizontalAlignment="Center" FontWeight="Bold" VerticalAlignment="Center" />
</DataTemplate>
</app1:EmptyDataTemplateBehavior1.EmptyDataTemplate>
</app1:EmptyDataTemplateBehavior1>
</i1:Interaction.Behaviors>
Thsnks in advance
I am sending you a sample project illustrating how you can define empty data template for different grids in separate tab items.
I hope that helps.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>