This is a migrated thread and some comments may be shown as answers.

No Record found message or Empty Template

13 Answers 552 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 28 Dec 2011, 07:58 AM
Hi All,

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

Sort by
0
Maya
Telerik team
answered on 28 Dec 2011, 08:08 AM
Hello Kevin,

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.


Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kevin
Top achievements
Rank 1
answered on 28 Dec 2011, 08:26 AM
Hi,

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
0
Maya
Telerik team
answered on 28 Dec 2011, 08:29 AM
Hi Kevin,

Please use FirstOrDefault() method in this case instead of index.  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Kevin
Top achievements
Rank 1
answered on 28 Dec 2011, 11:39 AM
Thanks it work.
Appreciate your effort!!
0
sandy
Top achievements
Rank 1
Iron
Veteran
answered on 26 Jan 2012, 12:43 AM
Hi,
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
0
Maya
Telerik team
answered on 26 Jan 2012, 07:52 AM
Hi Sandy,

Could you try the approach mentioned above calling FirstOrDefault() method instead of using an index ? Did you get the same exception ?  

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
sandy
Top achievements
Rank 1
Iron
Veteran
answered on 26 Jan 2012, 05:38 PM
am getting this error.
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
0
sandy
Top achievements
Rank 1
Iron
Veteran
answered on 26 Jan 2012, 06:03 PM
Thanks for giving reply.
i got it.
thanks a lot for posting such a good post. :)
0
Maya
Telerik team
answered on 26 Jan 2012, 06:05 PM
Hi Kevin,

You can get the root grid as:

//Option 1:
Grid rootGrid = _grid.ChildrenOfType<
Grid>().FirstOrDefault();
//Option 2: 
Grid rootGrid = _grid.ChildrenOfType<Grid>().ElementAt(0);
 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
sandy
Top achievements
Rank 1
Iron
Veteran
answered on 26 Jan 2012, 06:55 PM
Hi am getting this for only one grid. i have one tab control.
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..
0
Maya
Telerik team
answered on 27 Jan 2012, 07:57 AM
Hello,

You can try attaching the behavior from the blog post for each grid you want to have that functionality.
 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
sandy
Top achievements
Rank 1
Iron
Veteran
answered on 27 Jan 2012, 05:08 PM
Hi Maya,
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
0
Maya
Telerik team
answered on 30 Jan 2012, 09:32 AM
Hello Kevin,

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.

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Kevin
Top achievements
Rank 1
Answers by
Maya
Telerik team
Kevin
Top achievements
Rank 1
sandy
Top achievements
Rank 1
Iron
Veteran
Share this question
or