3 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 15 Jul 2009 Link to this post


    I have a hierarchical treeview.
    In one of the detail tables I set ShowHeadersWhenNoRecords to false.
    But I still get the headers shown as long as I have a "NoRecordsTemplate".

    When I remove this template and set "NoDetailRecordsText" to some value it works - no headers, the text is shown...
    BUT then I have no Commands available so I'm not able to insert a new record.

    The idea - when I have no records I want to display something like "Sorry no XXX available - you can create one..".
    In simple words - I want to display the caption (including commands) and the information text.
    The reason - I have a lot of detail tables (at the same level) and most of them are usually empty.
    So it would save a lot of space if I could avoid displaying the columns header with the filters.

    My hope was that ShowHeaders... could do this job -- but it does not.
    If I use it as it is -- I have no chance to add a new record.
    If I use a template (which would enable me to add an "Insert button") the headers are always shown.

    Did I miss something - or is this "by design"?


  2. Answer
    Pavel avatar
    904 posts

    Posted 21 Jul 2009 Link to this post

    Hi Manfred,

    If you want to hide only the header and the filtering items for a specific table when it has no records, you can do it by using the ItemCreated event handler of the Grid like this:

    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        if ((e.Item is GridFilteringItem || e.Item is GridHeaderItem) && e.Item.OwnerTableView.Name == "OurTableView"
            if (e.Item.OwnerTableView.PagingManager.DataSourceCount == 0) 
                e.Item.Display = false;            

    I am attaching a sample page for reference.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft R3 2016 release webinar banner
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 21 Jul 2009 Link to this post

    Thank you Pavel,

    exactly what I've been looking for!

Back to Top