mimic commanditem in commanditemtemplate

5 posts, 1 answers
  1. Morten
    Morten avatar
    267 posts
    Member since:
    Jul 2012

    Posted 20 Aug 2010 Link to this post

    I generally use the standard commanditem. However, when I use the commanditemtemplate I'd like it to look like the standard skinned commanditem (buttons, links, etc.).

    How do I best go about this?
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 23 Aug 2010 Link to this post

    Hi Morten,

    The easiest way is to use the same HTML code (or similar one) as the one that is used internally by RadGrid. Please inspect the command item HTML output and take what you need from there. The internal HTML output of the command item is wrapped by a table cell with a rgCommandCell CSS class. All the HTML code that you have to review is wrapped inside a <table> :

    <table border="0" style="width: 100%;" class="rgCommandTable">
    ......
    </table>


    By default, the command row uses the so called sprite buttons:

    http://www.telerik.com/help/aspnet-ajax/css-sprites.html

    Here is how to mimic such a button inside the RadGrid CommandItemTemplate:

    <asp:Button CssClass="rgAdd" Text=" " />

    The CSS class and the single-spaced Text property matter the most.


    Kind regards,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roger Barnes
    Roger Barnes avatar
    38 posts
    Member since:
    May 2008

    Posted 16 Dec 2010 Link to this post

    <CommandItemTemplate>
    <table border="0" style="width: 100%;" class="rgCommandTable">
    <tr>
        <td align="left">
        <asp:Button CommandName="InitInsert" runat="server" ID="btnAddNewRecord" Text=" " 
                    title="Add new record" CssClass="rgAdd" />
        <asp:LinkButton ID="lnkbAddNewRecord" CommandName="InitInsert" runat="server">
                Add
    new Record</asp:LinkButton>
        </td>
        <td>Your Custom Commands Here</td>
        <td align="right">                                    
        <asp:Button CommandName="RebindGrid" runat="server" ID="btnRefresh" Text=" "
                title="Refresh" CssClass="rgRefresh" />
        <asp:LinkButton ID="lnkbRefresh" CommandName="RebindGrid" runat="server">Refresh</asp:LinkButton>
         </td>
      </tr>
    </table>
    </CommandItemTemplate>
  5. Vasssek
    Vasssek avatar
    143 posts
    Member since:
    Aug 2010

    Posted 28 Aug in reply to Roger Barnes Link to this post

    Hello,

     

    I know this is 6years old topic, but what If I want to use commanditemtemplate and RadGrid render mode is set to Auto or Lightweight ? Then all command buttons are without css images.

    Please help.

    Best regards

    Vasssek

  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 01 Sep Link to this post

    Hi Vasssek,

    Generally, you can use the auto-generated CommandItem and add your additional controls during the ItemCreated event handler. Could you elaborate on your specific requirement and send us sample videos or screenshots demonstrating the desired appearance?

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017