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

ShowHeadersWhenNoRecords and CommandItemTemplate

3 Answers 210 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 13 Mar 2008, 09:12 PM
Im having in issue using a hierarchy grid.  In my GridTableView I have a CommandItemTemplate with an InitInsert CommantItem that works perfectly when there is data in the DetailTable and the header is showing.  The problem is that I also have ShowHeadersWhenNoRecords = False for that same GridTableView. 

When there is no data, it hides the headers like it should but it also hides the CommandItemTemplate so that no records can be added.  This also happens when I'm using the default CommandItem instead of a CommandItemTemplate.

Is there anyway to get the CommandItemTemplate to show if there is not data, but still hide the headers?  Here is a sample of my code...

<DetailTables> 
        <telerik:GridTableView runat="server" ShowHeader="true" DataKeyNames="ChecklistId"  NoDetailRecordsText="" ShowHeadersWhenNoRecords="false"   
        EditMode="InPlace" Name="Checklist" CommandItemDisplay="top" Width="100%" HorizontalAlign="Right" CellPadding="0" CellSpacing="0">  
            <CommandItemTemplate> 
                <asp:LinkButton ID="btnAddNew" runat="server" CommandName="InitInsert" Text="Add New Record" CssClass="gridLink" /> 
            </CommandItemTemplate> 
........ 

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 17 Mar 2008, 03:11 PM
Hello Chad,

Unfortunately this is not possible because the command item is part of the table header and will not be rendered when you have no items in a nested table and choose ShowHeadersWhenNoRecords = false. You should either set ShowHeadersWhenNoRecords = true or trigger an insert action from the parent table as demonstrated in this code library entry:

http://www.telerik.com/community/code-library/submission/b311D-dthhb.aspx

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ricardo Pinto
Top achievements
Rank 1
answered on 15 Jan 2010, 09:22 AM
Hello!

I was wondering if it is still not possible to do what Chad intended to... I have the same requirement for a detailTable: I would like to hide the column headers (in the case there are no records) but show the commandItem, so that the user can click the New Record button.

Could you please consider changing the ShowHeaders property?
My suggestion would be to change from the True/False values to an enumeration:
  • None
  • CommandItemOnly
  • ColumnHeadersOnly
  • All

Thanks in advance and have a great year!

Ricardo.
0
Radoslav
Telerik team
answered on 20 Jan 2010, 03:01 PM
Hello Ricardo,

Currently is still not possible to hide the column headers but show the CommandItem.

Additionally in your scenario you could add a different button which is placed out of the GridTableView and show this button when the details table does not have any items. When user click on this button you could show Add Form.

Another approach is to use javascript or jQuery and remove the table's row which represent GridTableView header. When  the GridTableView is rendered the header and the CommandItem are placed in thead tag. So you could get this tag and remove its first row from the DOM :
<thead>
<--Row for the header->
<tr class="rgCommandRow"></tr>
<--Row for the CommandItem-->
<tr></tr>
</thead>

Also thank you for the suggestion - I will forward it to our development department to be considered further.

I hope this helps. If further questions arise, do let me know.

Greetings,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Chad
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Ricardo Pinto
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or