changing back color

7 posts, 1 answers
  1. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 30 Apr 2010 Link to this post

    hi

    how cn i change the back color of the row where i expanded a detail table?

    thanks and regards
    webster velasco
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Apr 2010 Link to this post

    Hello,

    Try the following client side code in "OnHierarchyExpanded" event to change the background color of row, when expanding.

    Client code:

     
    <script type="text/javascript">   
     function HierarchyExpanded(sender, eventargs) {   
        eventargs.get_gridDataItem().get_element().style.backgroundColor = "red";   
        eventargs.get_gridDataItem().get_element().style.backgroundImage = "none";   
        }   
    </script>  

    -Shinu.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 30 Apr 2010 Link to this post

    ur code isnt firing
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 Apr 2010 Link to this post

    Hello,

    I missed to mention that, I am using HierarchyLoadMode as "ClientSide" in my application and since the client side event fires when expanding the row. If you are using ServerBind option, then try the following code and see whether it helps.

    C#:

     
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)  
        {  
            if (e.CommandName == RadGrid.ExpandCollapseCommandName)  
            {  
                (e.Item as GridDataItem).BackColor = System.Drawing.Color.Red;  
            }  
        } 

    -Shinu.

  6. Webster Velasco
    Webster Velasco avatar
    114 posts
    Member since:
    Jun 2012

    Posted 30 Apr 2010 Link to this post

    thanks shinu..

    how can i revert the backcolr if its not expanded anymore?
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 30 Apr 2010 Link to this post

    Hi,

    I have modified the above code in order to achieve the required functionality. Give a try with this code.

    CS:
     
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
        { 
            if (e.CommandName == RadGrid.ExpandCollapseCommandName) 
            { 
                GridDataItem item = (GridDataItem) e.Item; 
                if (item.Expanded) 
                { 
                    if (item.ItemIndex % 2 == 0) 
                    { 
                        item.BackColor = System.Drawing.Color.Transparent; 
                        item.CssClass = "rgRow"
                    } 
                    else 
                    { 
                        item.BackColor = System.Drawing.Color.Transparent; 
                        item.CssClass = "rgAltRow"
                    } 
                } 
                else 
                { 
                    item.BackColor = System.Drawing.Color.Red; 
                } 
            } 
        } 


    Regards,
    Princy.
  8. paul
    paul avatar
    6 posts
    Member since:
    Aug 2012

    Posted 24 Feb 2011 Link to this post

    Hi Shinu,
    I know this is an old thread but I hope I could still get some help.

    I tried this code and when i firebug i can see that the background -color attribute has been set to red but the grid still shows the same background color.

    My grid has load mode = Client and the event is firing after expanded but the color doesnt change;

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017