是否可以将GridView(与jQuery的tablesorter
一起)设置为交替行颜色,但更改每个列分组的颜色集合?参见下图:使用列分组颜色添加交替行颜色 - 是否有可能?
我目前硬编码我已经创建基于阵列的单元的背景颜色,例如greenArray是一个整数数组,设置为(0,1,2,3),purpleArray是(4,5,6,7)等。但是,当我使用tablesorter插件时,显然单元格保持其颜色,这会弄乱交替的颜色方案:
编辑:我目前正在增加背景颜色VB.NET。下面的函数定义了阵列,然后调用实际上施加造型一个ColorizeMe()函数:
Private Sub StyleTable(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gvReport.RowDataBound
'Define arrays to color the gridview, if cell index is in array, it will be colored
Dim blueArray() As Integer = {0, 17, 18, 19, 20}
Dim greenArray() As Integer = {1, 2, 3, 4}
Dim purpleArray() As Integer = {5, 6, 7, 8}
Dim pinkArray() As Integer = {9, 10, 11, 12}
Dim yellowArray() As Integer = {13, 14, 15, 16}
_packworks.ColorizeMe(blueArray, greenArray, purpleArray, pinkArray, yellowArray, e.Row)
End Sub
而ColorizeMe()函数:
Public Sub ColorizeMe(ByVal blueArray() As Integer, ByVal greenArray() As Integer, _
ByVal purpleArray() As Integer, ByVal pinkArray() As Integer, _
ByVal yellowArray() As Integer, ByVal row As GridViewRow)
Dim i As Integer = 0
For Each cell As TableCell In row.Cells
If Array.IndexOf(blueArray, i) <> -1 Then
If _isDark Then 'Color account column
cell.BackColor = ColorTranslator.FromHtml("#B0C4DE")
Else
cell.BackColor = ColorTranslator.FromHtml("#E6E6FA")
End If
ElseIf Array.IndexOf(greenArray, i) <> -1 Then
If _isDark Then
cell.BackColor = ColorTranslator.FromHtml("#a4d5a8")
Else
cell.BackColor = ColorTranslator.FromHtml("#ddf5de")
End If
ElseIf Array.IndexOf(purpleArray, i) <> -1 Then
If _isDark Then
cell.BackColor = ColorTranslator.FromHtml("#ada4d4")
Else
cell.BackColor = ColorTranslator.FromHtml("#c7c6f4")
End If
ElseIf Array.IndexOf(pinkArray, i) <> -1 Then
If _isDark Then
cell.BackColor = ColorTranslator.FromHtml("#e3b3e0")
Else
cell.BackColor = ColorTranslator.FromHtml("#fae1fa")
End If
ElseIf Array.IndexOf(yellowArray, i) <> -1 Then
If _isDark Then
cell.BackColor = ColorTranslator.FromHtml("#e0e3ab")
Else
cell.BackColor = ColorTranslator.FromHtml("#f5f8dd")
End If
End If
i += 1
Next
_isDark = Not _isDark
End Sub
你可以发布适用代码的小提琴吗?这是可能的,但是现在看到你正在处理的事情会更容易。 –
我希望我可以发表小提琴。我目前在服务器端添加了.NET中的颜色背景,我只是很好奇,如果我能够在jQuery中完成相同的功能,对语言知之甚少。但是,如果能帮助您深入了解我的想法,我确实会将我的服务器端代码添加到描述中。我有几个不同栏需要着色的页面,所以我决定这些数组是最好的选择。 – TimeBomb006