Problem with CommandItemStyle

4 posts, 0 answers
  1. Dany Thielen
    Dany Thielen avatar
    4 posts
    Member since:
    Apr 2008

    Posted 04 Feb 2009 Link to this post

    Hello,


    I encounter a strange problem when trying to apply different styles for different hierarchy levels on RadGrid.
    I'm using the same approach as described in following article:
    http://www.telerik.com/help/aspnet-ajax/grddifferentstylesineachhierarchylevelwithskin.html
    All works fine for HeaderStyle, ItemStyle and AlternatingItemStyle. However as soon as I try to apply a new style to CommandItemStyle, RadGrid behaves in a weired way:
    Applying style "OuterItemStyle" on the CommandItemStyle of the MasterTable works, but applying "InnerItemStyle" to the first DetailTable CommandItemStyle doesn't work at all.
    Some snippets of my code:




    <style type="text/css">
       .OuterItemStyle
       {
         background: #90979E !important;
         color: black !important;
         /*add more style definitions here*/
       }
      
       .........

       .InnerItemStyle
       {
         background: #E0E1E2 !important;
         color: black !important;
         /*add more style definitions here*/
       }
     
       }
    </style>

    .......

    <telerik:RadGrid runat="server" .... >

    <MasterTableView CommandItemDisplay="Top" ... >
        <ItemStyle CssClass="OuterItemStyle" />
        <CommandItemStyle CssClass="OuterItemStyle" />

       ...............

       <DetailTables>
        <telerik:GridTableView  CommandItemDisplay="Top".......>
            <ItemStyle CssClass="InnerItemStyle" />
                <CommandItemStyle CssClass="InnerItemStyle" />

    ........

    When inspecting the source code of the generated page in the Dom-Inspector, I see that the "OuterItemStyle" css class has been applied to the CommandItem of the MasterTable but no class has been applied to the DetailTable.
    It seems as if the line <CommandItemStyle CssClass="InnerItemStyle" /> isn't affecting any value...
    Is this a problem of RadGrid or did I just missed a thing?

    Any help is highly appreciated,

    Thanks a lot

    Dany
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 09 Feb 2009 Link to this post

    Hello Dany,

    You may want to ensure that the skin is not everriding any settings applied through the tag. Temporary set Skin="" to verify this, and see of the setting is then applied.

    All the best,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lukrs
    Lukrs avatar
    39 posts
    Member since:
    Sep 2012

    Posted 10 Mar 2009 Link to this post

    Hi,

    I tried that too, and it doesn,t work at all.

     <CommandItemStyle CssClass="detailTableCommand" />


    This works.....

    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
            if ((e.Item is GridCommandItem)) 
            { 
                GridCommandItem commandItem = e.Item as GridCommandItem; 
                if (((Telerik.Web.UI.GridItem)(commandItem)).OwnerTableView.Name == "TableName"
                { 
                    // your code
                } 
            } 
        } 



    LP, Luka
  5. Dany Thielen
    Dany Thielen avatar
    4 posts
    Member since:
    Apr 2008

    Posted 10 Mar 2009 Link to this post

    Hello Luka,

    That's exactly the workaround I'm using too. Setting the color programmtically with e.Item.OwnerTableView.CommandItemStyle.BackColor

    Cheerio

    Dany
Back to Top