JQuery表格分类器插件样式

时间:2012-04-11 09:18:48

标签: c# tablesorter

我昨天实现了表格分类器,如果某个时间少于当前时间,我想要更改单元格的颜色,如果它们失败,我想要更改单元格红色这是我的C#代码我们原来刚刚一个工作正常的gridView但是我们想要改变它以便更快地对c#Code

进行分类

 protected void gvResult_rowDataBound(Object sender, GridViewRowEventArgs e)
        {
            DateTime AppointmentTime = DateTime.Now;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                AppointmentTime = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "AppointmentTime"));

                if (AppointmentTime < DateTime.Now)
                {

                    e.Row.CssClass = "gvRowRed";
                    e.Row.Cells[0].CssClass = "white";
                    e.Row.Cells[1].CssClass = "white";
                    e.Row.Cells[2].CssClass = "white";
                    e.Row.Cells[3].CssClass = "white";
                    e.Row.Cells[4].CssClass = "white";
                    e.Row.Cells[5].CssClass = "white";
                    e.Row.Cells[6].CssClass = "white";
                    e.Row.Cells[7].CssClass = "white";
                }
                else if (AppointmentTime > DateTime.Now && AppointmentTime < DateTime.Now.AddHours(1))
                {
                    e.Row.CssClass = "gvRowGreen";
                    e.Row.Cells[0].CssClass = "white";
                    e.Row.Cells[1].CssClass = "white";
                    e.Row.Cells[2].CssClass = "white";
                    e.Row.Cells[3].CssClass = "white";
                    e.Row.Cells[4].CssClass = "white";
                    e.Row.Cells[5].CssClass = "white";
                    e.Row.Cells[6].CssClass = "white";
                    e.Row.Cells[7].CssClass = "white";
                }
            }


       }

protected void gvResult_rowDataBound(Object sender, GridViewRowEventArgs e) { DateTime AppointmentTime = DateTime.Now; if (e.Row.RowType == DataControlRowType.DataRow) { AppointmentTime = Convert.ToDateTime(DataBinder.Eval(e.Row.DataItem, "AppointmentTime")); if (AppointmentTime < DateTime.Now) { e.Row.CssClass = "gvRowRed"; e.Row.Cells[0].CssClass = "white"; e.Row.Cells[1].CssClass = "white"; e.Row.Cells[2].CssClass = "white"; e.Row.Cells[3].CssClass = "white"; e.Row.Cells[4].CssClass = "white"; e.Row.Cells[5].CssClass = "white"; e.Row.Cells[6].CssClass = "white"; e.Row.Cells[7].CssClass = "white"; } else if (AppointmentTime > DateTime.Now && AppointmentTime < DateTime.Now.AddHours(1)) { e.Row.CssClass = "gvRowGreen"; e.Row.Cells[0].CssClass = "white"; e.Row.Cells[1].CssClass = "white"; e.Row.Cells[2].CssClass = "white"; e.Row.Cells[3].CssClass = "white"; e.Row.Cells[4].CssClass = "white"; e.Row.Cells[5].CssClass = "white"; e.Row.Cells[6].CssClass = "white"; e.Row.Cells[7].CssClass = "white"; } } }

它的第一部分我现在专注于所以如果约会时间少于datetime.now我需要将单元格背景颜色和白色字体的颜色着色但是由于某种原因背景颜色不会改变,只有颜色该字体可以提供任何帮助。

继承人CSS

table.tablesorter {
    font-family:arial;
    background-color: #CDCDCD;
    margin:10px 0pt 15px;
    width: 100%;
    text-align: left;
}
table.tablesorter thead tr th, table.tablesorter tfoot tr th {
    background-color: #336699;
    border: 1px solid black;
    padding: 10px 15px;
    vertical-align:middle;
    font:verdana;
    color:White;
}
table.tablesorter thead tr .header {
    background-image: url('/img/bg/bg.gif');
    background-repeat: no-repeat;
    background-position: center right;
    cursor: pointer;
}
table.tablesorter tbody td {
    color: #3D3D3D;
    padding: 4px;
    background-color: #FFF;
    vertical-align: top;
}
table.tablesorter tbody tr.odd td {
    background-color:#F0F0F6;
}
table.tablesorter thead tr .headerSortUp {
    background-image: url('/img/bg/asc.gif') ;
    background-repeat: no-repeat;
    background-position: center right;
}
table.tablesorter thead tr .headerSortDown {
    background-image: url('/img/bg/desc.gif');
    background-repeat: no-repeat;
    background-position: center right;
}
table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSortUp {
background-color: #8dbdd8;
}

.gvRowRed
{
    background-color:Red !important;
}

.white
{
color:#ffffff !important;
}

1 个答案:

答案 0 :(得分:0)

尝试更改

.gvRowRed
{
    background-color:Red !important;
}

.gvRowRed td
{
    background-color:Red !important;
}

和gvRowGreen一样 - 它将类应用于行而不是单元格。