1

我正在使用 devexpress 的 aspxgridview。我在单元格上应用了不同的单元格样式颜色。现在我想将网格的备用行设置为阴影(相同颜色的光)。我正在应用交替颜色,但即使在设置 cellstyle-color 时也不会应用它。请任何人对此有任何想法。提前致谢。

4

2 回答 2

0

我建议您使用 DevExpress css 样式(而不是设置 ASPxGridView 的属性),如下所示:

.dxgvDataRow:hover
 {
   color: gray;
 }

您还可以使用 ASPxGridView 的 CssPostfix 属性为控件设置不同的样式。例如:

<dx:ASPxGridView ID="grid" runat="server"  Styles-CssPostfix="MyGrid" ...

将使用以下CSS:

.dxgvDataRow_MyGrid:hover
 {
   color: gray;
 }

要观察 ASPx css 类名称,只需在开发模式下打开浏览器并查看源代码,您可以找到这样的类:dxgvDataRowHover、dxgvFocusedRow、dxgvSelectedRow 和许多其他类。

这种样式自定义的优点是html标记不会为每个html元素创建样式属性,css编辑更容易更快,并且不需要通过设置属性来自定义每个ASPxGridView控件。

于 2013-07-26T09:46:33.523 回答
0

谢谢安东,但我已经用 javascript 完成了。我正在使用如下表的偶数和奇数属性。这是我在 document.ready 函数中调用的函数。并且还从服务器端调用每个按钮的单击事件。

功能颜色网格(){

        /*code for color coding grid*/
        $(".student_account td table tbody tr'[id]':odd").addClass('initial');
        $(".student_account td table tbody tr'[id]':even").addClass('initial');

        /* For odd Rows */

        // for first 3 columns
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(1)").css("background-color", "#EEEEEE");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(2)").css("background-color", "#EEEEEE");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(3)").css("background-color", "#EEEEEE");

        // for 4th and 5th column
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(4)").css("background-color", "#EBFAE3");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(5)").css("background-color", "#EBFAE3");


        // for 6th t0 9th column
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(6)").css("background-color", "#F7F8D6");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(7)").css("background-color", "#F7F8D6");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(8)").css("background-color", "#F7F8D6");
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(9)").css("background-color", "#F7F8D6");


        // for 10th column
        $(".student_account td table tbody tr'[id]':odd  td:nth-child(10)").css("background-color", "#CBE6F7");



        /* For Even Rows */

        var name = "ctl00_ContentPlaceHolder1_grdScheduleStudent_DXHeadersRow";

        // for first 3 columns
        $(".student_account td table tbody tr'[id]':even  td:nth-child(1)").css("background-color", "#FFFFFF");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(2)").css("background-color", "#FFFFFF");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(3)").css("background-color", "#FFFFFF");

        // for 4th and 5th column
        $(".student_account td table tbody tr'[id]':even  td:nth-child(4)").css("background-color", "#F5FAF3");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(5)").css("background-color", "#F5FAF3");


        // for 6th t0 9th column
        $(".student_account td table tbody tr'[id]':even  td:nth-child(6)").css("background-color", "#FBFCEA");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(7)").css("background-color", "#FBFCEA");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(8)").css("background-color", "#FBFCEA");
        $(".student_account td table tbody tr'[id]':even  td:nth-child(9)").css("background-color", "#FBFCEA");


        // for 10th column
        $(".student_account td table tbody tr'[id]':even  td:nth-child(10)").css("background-color", "#EDF8FE");

        $(".student_account td table tbody tr'[id=" + name + "]' td").css("background-color", "#56A52E");

        /*end color coding*/
    }
于 2013-08-01T05:56:51.313 回答