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

Problem with CommandItemStyle

3 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dany Thielen
Top achievements
Rank 1
Dany Thielen asked on 04 Feb 2009, 09:27 AM
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

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 09 Feb 2009, 07:41 AM
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.
0
Lukrs
Top achievements
Rank 2
answered on 10 Mar 2009, 10:23 AM
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
0
Dany Thielen
Top achievements
Rank 1
answered on 10 Mar 2009, 01:03 PM
Hello Luka,

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

Cheerio

Dany
Tags
Grid
Asked by
Dany Thielen
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Lukrs
Top achievements
Rank 2
Dany Thielen
Top achievements
Rank 1
Share this question
or