AspXGridView鼠标经过改变行背景色与自定义列显示内容

/// <summary>
        /// 改变行背景色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grid_HtmlRowPrepared(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType == DevExpress.Web.ASPxGridView.GridViewRowType.Data) 
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#e3f1d1';");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            }
        }

 

 

        /// <summary>
        /// 自定义列显示内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grid_CustomColumnDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDisplayTextEventArgs e)
        {
            if (e.Column.Caption == "申请人")
            {
                e.DisplayText = GetUserName(int.Parse(e.GetFieldValue("ReqUser").ToString()));
            }
            if (e.Column.Caption == "当前状态")
            {
                if (e.GetFieldValue("ConfirmDate") != null)
                {
                    e.DisplayText = "已交付";
                }
                else if (e.GetFieldValue("ApproveDate") != null)
                {
                    e.DisplayText = "已批准";
                }
                else
                {
                    e.DisplayText = "等待批准";
                }
            }
        }

  

posted @ 2013-02-27 10:09  小锋神  阅读(1119)  评论(0编辑  收藏  举报