Command Button in Grid ItemTemplate?

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    7 posts
    Member since:
    Aug 2009

    Posted 20 Sep 2009 Link to this post

        Hi.  I'm in the process of converting a RadGrid using "traditional" columns to CardView, using ItemTemplate.  In the original grid, I had a GridButtonColumn to handle deleting, with a confirmation pop-up.  I want to keep this same behavior in the template.  Is there a way I can embed the original button column's behavior in the new template?

    Thanks,
        Andrew

    Here's my old grid:
                    <telerik:RadGrid ID="ContentsRadGrid" runat="server" 
                        GridLines="None" 
                        OnNeedDataSource="ContentsRadGrid_NeedDataSource"   
                        ondeletecommand="ContentsRadGrid_DeleteCommand">  
                        <MasterTableView AutoGenerateColumns="false">  
                            <RowIndicatorColumn> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn> 
                                <HeaderStyle Width="20px"></HeaderStyle> 
                            </ExpandCollapseColumn> 
                            <Columns> 
                                <telerik:GridBoundColumn HeaderText="Quantity" DataField="Quantity" /> 
                                <telerik:GridBoundColumn HeaderText="NDC" DataField="TheDrug.Ndc" /> 
                                <telerik:GridBoundColumn HeaderText="Name" DataField="TheDrug.DrugName" /> 
                                <telerik:GridBoundColumn HeaderText="Size" DataField="TheDrug.DrugSize" /> 
                                <telerik:GridBoundColumn HeaderText="Strength" DataField="TheDrug.DrugStrength" /> 
                                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn" 
                                    ConfirmText="Delete medication from kit list?" /> 
                            </Columns> 
                        </MasterTableView> 
                    </telerik:RadGrid> 
     

    And here's the new one, so far:
                    <telerik:RadGrid ID="RadGrid1" runat="server" 
                        GridLines="None" 
                        OnNeedDataSource="RadGrid1_NeedDataSource"   
                        ondeletecommand="ContentsRadGrid_DeleteCommand">  
                        <MasterTableView AutoGenerateColumns="false">  
                            <Columns> 
                                <telerik:GridBoundColumn HeaderText="Quantity" DataField="Quantity" Visible="false" /> 
                            </Columns> 
                            <ItemTemplate> 
                                <table style="width:100%;">  
                                    <tr> 
                                        <td rowspan="2" style="text-align:center; width:15%">  
                                            Qty:<br /> 
                                            <%# Eval("Quantity") %> 
                                        </td> 
                                        <td colspan="2" style="white-space:nowrap;">  
                                            <%# Eval("TheDrug.Ndc.NdcString") %>&nbsp;  
                                            <span style="font-weight:bold;"><%# Eval("TheDrug.DrugName") %></span>  
                                        </td> 
                                        <td rowspan="2" style="text-align:center; width:10%">  
                                            DELETE LINK GOES HERE  
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style="white-space:nowrap;">  
                                            Strength:&nbsp;  
                                            <%# Eval("TheDrug.DrugStrength") %> 
                                        </td> 
                                        <td style="white-space:nowrap;">  
                                            Size:&nbsp;  
                                            <%# Eval("TheDrug.DrugSize") %> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </ItemTemplate> 
                        </MasterTableView> 
                    </telerik:RadGrid> 
     


  2. lakmal
    lakmal avatar
    76 posts
    Member since:
    Jun 2009

    Posted 20 Sep 2009 Link to this post

    Yes you can do it

    <ItemTemplate> 
                                <table style="width:100%;">  
                                    <tr> 
                                        <td rowspan="2" style="text-align:center; width:15%">  
                                            Qty:<br /> 
                                            <%# Eval("Quantity") %> 
                                        </td> 
                                        <td colspan="2" style="white-space:nowrap;">  
                                            <%# Eval("TheDrug.Ndc.NdcString") %>&nbsp;  
                                            <span style="font-weight:bold;"><%# Eval("TheDrug.DrugName") %></span>  
                                        </td> 
                                        <td rowspan="2" style="text-align:center; width:10%">  
                                            DELETE LINK GOES HERE  
                                        </td> 
                                    </tr> 
                                    <tr> 
                                        <td style="white-space:nowrap;">  
                                            Strength:&nbsp;  
                                            <%# Eval("TheDrug.DrugStrength") %> 
                                        </td> 
                                        <td style="white-space:nowrap;">  
                                            Size:&nbsp;  
                                            <%# Eval("TheDrug.DrugSize") %> 
                                        </td> 
                                    </tr> 
                                </table> 
                            </ItemTemplate>

      <Columns>
    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"                                  ConfirmText="Delete medication from kit list?" />







         </Columns>






  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    7 posts
    Member since:
    Aug 2009

    Posted 20 Sep 2009 Link to this post

    Thanks for the quick response.  This is a good start -- the column appears and works.  Is there a way I can get it to appear at the end of the row, as indicated in my markup?  (As written it appears before the template in each row.)

    Thanks,
      Andrew
  5. Andrew
    Andrew avatar
    7 posts
    Member since:
    Aug 2009

    Posted 21 Sep 2009 Link to this post

        Never mind, I figured it out.  I needed to embed my ItemTemplate within the GridTemplateColumn.

    Thanks,
        Andrew
Back to Top