No Record found message or Empty Template

14 posts, 0 answers
  1. Kevin
    Kevin avatar
    24 posts
    Member since:
    Jul 2011

    Posted 28 Dec 2011 Link to this post

    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.

  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 28 Dec 2011 Link to this post

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

  3. Kevin
    Kevin avatar
    24 posts
    Member since:
    Jul 2011

    Posted 28 Dec 2011 Link to this post

    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
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 28 Dec 2011 Link to this post

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

  5. Kevin
    Kevin avatar
    24 posts
    Member since:
    Jul 2011

    Posted 28 Dec 2011 Link to this post

    Thanks it work.
    Appreciate your effort!!
  6. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 25 Jan 2012 Link to this post

    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
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Jan 2012 Link to this post

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

  8. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 26 Jan 2012 Link to this post

    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
  9. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 26 Jan 2012 Link to this post

    Thanks for giving reply.
    i got it.
    thanks a lot for posting such a good post. :)
  10. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Jan 2012 Link to this post

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

  11. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 26 Jan 2012 Link to this post

    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..
  12. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 27 Jan 2012 Link to this post

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

  13. sandy
    sandy avatar
    23 posts
    Member since:
    Aug 2010

    Posted 27 Jan 2012 Link to this post

    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
  14. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 30 Jan 2012 Link to this post

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

Back to Top