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

[Solved] Using custom commanditem template with details tables

2 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
adi
Top achievements
Rank 1
adi asked on 05 Oct 2009, 12:59 PM
Hi,

I'd like to use my custom commanditem template with details tables in a hierachy view like this sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/commanditem/defaultcs.aspx
.

How can I set the visibility of my commanditem buttons for the detailtables? Sample uses e.g. <%# RadGrid1.EditIndexes.Count = 0 %>. But this is not applicable with detailtables.

<asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count = 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Edit selected</asp:LinkButton> 

2 Answers, 1 is accepted

Sort by
0
Accepted
Sebastian
Telerik team
answered on 06 Oct 2009, 09:09 AM
Hello Adi,

Try the following command item template definition for your detail table to see whether this produces the desired result:

<CommandItemTemplate> 
                    Custom command item template &nbsp;  
                    <asp:LinkButton Style="vertical-align: bottom" ID="Linkbutton5" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Edit.gif" /> Edit Selected Orders</asp:LinkButton> 
                    <asp:LinkButton ID="Linkbutton6" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Update.gif" /> Update Orders</asp:LinkButton> 
                    &nbsp;  
                    <asp:LinkButton ID="Linkbutton7" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Cancel.gif" /> Cancel editing</asp:LinkButton> 
                    &nbsp;  
                    <asp:LinkButton ID="Linkbutton8" runat="server" CommandName="InitInsert" Visible='<%# !(Container as GridCommandItem).OwnerTableView.IsItemInserted %>'><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/AddRecord.gif" /> Add new Order</asp:LinkButton> 
                    <asp:LinkButton ID="Linkbutton9" runat="server" CommandName="PerformInsert" Visible='<%# (Container as GridCommandItem).OwnerTableView.IsItemInserted %>'><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Insert.gif" /> Add this Order</asp:LinkButton> 
                    &nbsp;  
                    <asp:LinkButton ID="Linkbutton10" runat="server" CommandName="DeleteSelected"><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Delete.gif" /> Delete Selected Orders</asp:LinkButton> 
                    &nbsp;&nbsp;&nbsp;  
                    <asp:LinkButton ID="Linkbutton11" runat="server" CommandName="RebindGrid"><img style="border:0px" alt="" src="RadControls/Grid/Skins/Default/Refresh.gif" /> Refresh orders list</asp:LinkButton> 
                    <br /> 
                    &nbsp;  
                  
</CommandItemTemplate> 

Best regards,
Sebastian
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.
0
adi
Top achievements
Rank 1
answered on 06 Oct 2009, 09:53 AM
Hi Sebastian,

thank you. This works.
Here is the implementation for VB users:
<CommandItemTemplate> 
        <div style="padding: 5px 5px;">  
            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count = 0 %>'>  
                <asp:Image ID="Image1" runat="server" Style="border: 0px; vertical-align: middle;" AlternateText="" /> 
                Edit  
            </asp:LinkButton> 
            &nbsp;&nbsp;  
            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'>  
                <asp:Image ID="Image2" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
                Update  
            </asp:LinkButton> 
            &nbsp;&nbsp;  
            <asp:LinkButton ID="LinkButton3" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 Or CType(Container, GridCommandItem).OwnerTableView.IsItemInserted %>'>  
                <asp:Image ID="Image3" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
                Cancel  
            </asp:LinkButton> 
            &nbsp;&nbsp;  
            <asp:LinkButton ID="LinkButton4" runat="server" CommandName="InitInsert" Visible='<%# Not CType(Container, GridCommandItem).OwnerTableView.IsItemInserted %>'>  
                <asp:Image ID="Image4" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
                Add  
        </asp:LinkButton> 
        &nbsp;&nbsp;  
        <asp:LinkButton ID="LinkButton5" runat="server" CommandName="PerformInsert" Visible='<%# CType(Container, GridCommandItem).OwnerTableView.IsItemInserted %>'>  
                <asp:Image ID="Image5" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
            Insert  
            </asp:LinkButton> 
            &nbsp;&nbsp;  
            <asp:LinkButton ID="LinkButton6" OnClientClick="javascript:return confirm('Delete all selected?')" runat="server" 
 CommandName="DeleteSelected">  
                <asp:Image ID="Image" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
                Delete  
            </asp:LinkButton> 
            &nbsp;&nbsp;  
            <asp:LinkButton ID="LinkButton7" runat="server" CommandName="RebindGrid">  
            <asp:Image ID="Image7" runat="server" AlternateText="" Style="border: 0px; vertical-align: middle;" /> 
                Refresh  
            </asp:LinkButton> 
        </div> 
</CommandItemTemplate> 
Tags
Grid
Asked by
adi
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
adi
Top achievements
Rank 1
Share this question
or