I am using the "NeedDataSource" method to fill in a grid. On the ItemDataBound I am setting the background colors for some values in a couple of column cells. (Sub below)
This displays properly. Dragging columns around works properly and the colors follow the cells. However, when you do a grouping by dragging the column to the top of the grid the colors do not stay with the cells.
I have attached a before and after image...
Any ideas why this is moving? I am setting the colors based on the FindByUniqueName identifier for the column.
Thanks,
Nathan
This displays properly. Dragging columns around works properly and the colors follow the cells. However, when you do a grouping by dragging the column to the top of the grid the colors do not stay with the cells.
I have attached a before and after image...
Any ideas why this is moving? I am setting the colors based on the FindByUniqueName identifier for the column.
Thanks,
Nathan
Protected
Sub
rgDispatch_ItemDataBound(sender
As
Object
, e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
rgDispatch.ItemDataBound
'//Is it a GridDataItem
If
Not
IsNothing(TryCast(e.Item, Telerik.Web.UI.GridDataItem))
Then
'Get the instance of the right type
Dim
dataBoundItem
As
Telerik.Web.UI.GridDataItem =
DirectCast
(e.Item, Telerik.Web.UI.GridDataItem)
'Set the desired color on the Status column based on the value
Dim
StatusColIndex
As
Integer
= rgDispatch.Columns.FindByUniqueName(
"Status"
).OrderIndex
Select
Case
dataBoundItem(
"Status"
).Text
Case
"Loading"
dataBoundItem(
"Status"
).BackColor = System.Drawing.Color.Yellow
Case
"Loaded"
dataBoundItem(
"Status"
).BackColor = System.Drawing.Color.DodgerBlue
Case
"Claimed"
dataBoundItem(
"Status"
).BackColor = System.Drawing.Color.Orange
Case
"Started"
dataBoundItem(
"Status"
).BackColor = System.Drawing.Color.FromArgb(19, 229, 19)
'Green color
Case
"Stopped"
dataBoundItem(
"Status"
).BackColor = System.Drawing.Color.IndianRed
End
Select
'Set the desired color on the Status column based on the value
Dim
MatReadyColIndex
As
Integer
= rgDispatch.Columns.FindByUniqueName(
"MatReady"
).OrderIndex
Select
Case
dataBoundItem(
"MatReady"
).Text
Case
"Yes"
e.Item.Cells(MatReadyColIndex).BackColor = System.Drawing.Color.FromArgb(19, 229, 19)
Case
"No"
e.Item.Cells(MatReadyColIndex).BackColor = System.Drawing.Color.IndianRed
End
Select
End
If
If
Not
IsNothing(TryCast(e.Item, Telerik.Web.UI.GridPagerItem))
Then
Dim
pager
As
Telerik.Web.UI.GridPagerItem =
DirectCast
(e.Item, Telerik.Web.UI.GridPagerItem)
Dim
PagerLabel
As
Label = pager.FindControl(
"ChangePageSizeLabel"
)
PagerLabel.Text =
"Items per Page"
End
If
End
Sub