網路上dx 的中文資料真低少
查個 如何客製依照欄位更改樣式花不少時間
希望可以讓特定種類的欄位 顏色能夠交錯顯示
分享一下改法
以下為前端winform
要加上 OnHtmlFieldValuePrepared 這可以更改樞紐的 field 名稱樣式 顏色
<dx:ASPxPivotGrid runat="server" ID="ASPxPivotGridView" OnHtmlFieldValuePrepared="ASPxPivotGridView_HtmlFieldValuePrepared" ClientInstanceName="ResultGrid" Width="100%" KeyFieldName="RID"
AutoGenerateColumns="False" DataSourceID="ExtendObjectDataSource1" >
在寫程式在 OnHtmlFieldValuePrepared 裡面
去判斷甚麼時候要上色
以下為vb.net
Protected Sub ASPxPivotGridView_HtmlFieldValuePrepared(sender As Object, e As PivotHtmlFieldValuePreparedEventArgs)
If (e.IsColumn) Then
Return
End If
Dim isOddRow As Boolean = True
Dim isinsTypeOddRow As Boolean = True
Dim CenterName_value As Object = CType(Nothing, Object)
Dim insType_Name_value As Object = CType(Nothing, Object)
因為樞紐的結構有 母群組 底下又有子群組 cell 需要用for 迴圈判斷這個cell是屬於哪一個group的cell 再來判斷顏色
For i = 0 To e.MinIndex
Dim CenterName_NewValue As Object = e.GetFieldValue(CenterName_id, i)
Dim newinsType_Name_Value As Object = e.GetFieldValue(InstrumentName_id, i)
If (CenterName_NewValue IsNot CenterName_value) Then
CenterName_value = CenterName_NewValue
isOddRow = Not isOddRow
End If
If (newinsType_Name_Value IsNot insType_Name_value) Then
insType_Name_value = newinsType_Name_Value
isinsTypeOddRow = Not isinsTypeOddRow
End If
Next
If ((Object.ReferenceEquals(e.Field, CenterName_id) Or Object.ReferenceEquals(e.Field, insType_Name_id))) Then
ElseIf (isinsTypeOddRow) Then
e.Cell.BackColor = Color.FromArgb(91, 112, 180)
ElseIf (Not isinsTypeOddRow) Then
End If
End Sub
完成
有問題再留言問我
謝謝
歡迎高手低手來看看 指教指教 切磋切磋 教學香腸