Rad:Grid Change Row BackGround Color (RadGrid)

本文介绍了一种在Telerik RadGrid中更改展开和折叠行背景颜色的方法。通过检测RadGrid的ExpandCollapse命令,可以在行展开时改变当前行和其他行的颜色,并在行折叠时统一还原所有行的颜色。

Change the back color of the expanded row and the collapsed rows.

 

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

        //Expand a row , update the backcolor of the expanded row and other rows.
        if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item.Expanded == false)
        {
            

          foreach (GridDataItem item2 in RadGrid1.MasterTableView.Items)
            {
                if (item2 == (GridDataItem)e.Item)
                {
                    item2.BackColor = System.Drawing.Color.White;
                }
                else
                {
                    item2.BackColor = System.Drawing.Color.Gainsboro;
                }
            }
        }

        

        //Collaps a row , update the backcolor of all rows.

        if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item.Expanded == true)
        {
            foreach (GridDataItem item2 in RadGrid1.MasterTableView.Items)
            {
                item2.BackColor = System.Drawing.Color.White;               
            }
        }  

    }

 

http://www.telerik.com/community/forums/aspnet-ajax/grid/rad-grid-change-row-background-color.aspx

http://www.telerik.com/community/forums/aspnet/grid/set-background-color-of-a-row-in-client-script.aspx

http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-row-background-colour-confliction.aspx

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值