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

ShowHeadersWhenNoRecords...

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 15 Jul 2009, 12:04 PM
Hi,

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

Regards

Manfred

2 Answers, 1 is accepted

Sort by
0
Accepted
Pavel
Telerik team
answered on 21 Jul 2009, 10:38 AM
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.

Regards,
Pavel
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.
0
ManniAT
Top achievements
Rank 2
answered on 21 Jul 2009, 10:44 AM
Thank you Pavel,

exactly what I've been looking for!

Regards
Manfred
Tags
Grid
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Pavel
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or