/
Default.aspx.vb
52 lines (46 loc) · 2.21 KB
/
Default.aspx.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Imports System
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DevExpress.Web.ASPxPivotGrid
Imports DevExpress.XtraPivotGrid
Namespace CellTemplates
Public Partial Class _Default
Inherits Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
ASPxPivotGrid1.CellTemplate = New CellTemplate()
End Sub
Private Class CellTemplate
Implements ITemplate
Private Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
Dim templateContainer As PivotGridCellTemplateContainer = CType(container, PivotGridCellTemplateContainer)
Dim field As PivotGridField = templateContainer.DataField
If field IsNot Nothing AndAlso Equals(field.Caption, "Percents") Then
Dim value As Integer = Convert.ToInt32(Convert.ToDecimal(templateContainer.Value) * 350)
Dim table As Table = New Table()
table.Width = Unit.Pixel(400)
templateContainer.Controls.Add(table)
Dim row As TableRow = New TableRow()
table.Controls.Add(row)
Dim cell As TableCell = New TableCell()
cell.Style.Add(HtmlTextWriterStyle.Padding, "0px")
cell.Width = Unit.Pixel(value)
cell.Height = Unit.Pixel(20)
If templateContainer.Item.RowValueType = PivotGridValueType.Total Then
cell.BackColor = Color.Blue
Else
cell.BackColor = Color.Red
End If
If templateContainer.Item.RowValueType = PivotGridValueType.GrandTotal Then cell.BackColor = Color.Green
row.Controls.Add(cell)
cell = New TableCell()
cell.Text = templateContainer.Item.Text
cell.Wrap = False
row.Controls.Add(cell)
Else
templateContainer.Controls.Add(New LiteralControl(templateContainer.Text))
End If
End Sub
End Class
End Class
End Namespace