This is a migrated thread and some comments may be shown as answers.

Problem with cellformatting and horizontal scroll

3 Answers 192 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Blas
Top achievements
Rank 1
Blas asked on 30 Jul 2010, 09:49 AM
Hello,

I have a grid with a status column in which I want to place a red o green ball depending the bound value. I've tried to do that with the next code:


Private Sub Grid_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) _
        Handles gridPedidos.CellFormatting, _
                gridChrono.CellFormatting, _
                gridCentros.CellFormatting, _
                gridIncidencias.CellFormatting, _
                gridIncidenciasPFR.CellFormatting, _
                gridPedidosWeb.CellFormatting
    e.CellElement.Image = Nothing
    Dim column As GridViewCommandColumn = TryCast(e.CellElement.ColumnInfo, GridViewCommandColumn)
    If column IsNot Nothing Then
        Select Case column.UniqueName
            Case "Txt"
                CType(e.CellElement.Children(0), RadButtonElement).Image = My.Resources.document_text
                CType(e.CellElement.Children(0), RadButtonElement).ImageAlignment = ImageLayout.Center
            Case "Datos"
                CType(e.CellElement.Children(0), RadButtonElement).Image = My.Resources.table_view
                CType(e.CellElement.Children(0), RadButtonElement).ImageAlignment = ImageLayout.Center
        End Select
    End If
    If e.CellElement.ColumnInfo.Name = "Status" AndAlso TypeOf e.CellElement.RowInfo Is GridViewDataRowInfo Then
        Dim Status As Integer = CInt(e.CellElement.RowInfo.Cells("Status").Value)
        If Status = 0 Then
            e.CellElement.Image = My.Resources.button_green
        Else
            e.CellElement.Image = My.Resources.button_red
        End If
        e.CellElement.Text = ""
    End If
End Sub

Executing the program the status column is draw right as you can see in the image1 attached. But scrolling horizontally right and left, the red and green balls are showed in other columns (image2)

Thanks in advance
Blas

3 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 04 Aug 2010, 06:30 PM
Hello Roberto Andrade Olivie,

Thank you for contacting us. In our latest release we added column virtualization. This enables using large number of columns without a performance lost. Only the cells that are currently visible are created. When scrolling cells are reused and this causes the issue. 

To solve the issue you should create custom cell and column. Please send us your project and we will do the necessary modifications for you.

I am looking forward to your reply.

Kind regards,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Accepted
Blas
Top achievements
Rank 1
answered on 18 Aug 2010, 11:20 AM
Hi Jack,

Thank you very much for your response.

Finally I've discovered that what makes cell formatting works properly is e.CellElement.Image = Nothing at the begining of the CellFormating procedure, and I didn't put it, although in my initial post code was indicated.

Private Sub RadGridView1_CellFormatting(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles RadGridView1.CellFormatting
      e.CellElement.Image = Nothing
      If e.CellElement.ColumnInfo.Name = "CategoryID" AndAlso TypeOf e.CellElement.RowInfo Is GridViewDataRowInfo Then
          Dim CategoryID As Integer = CInt(e.CellElement.RowInfo.Cells("CategoryID").Value)
          If (CategoryID Mod 2) = 0 Then
              e.CellElement.Image = My.Resources.button_green
          Else
              e.CellElement.Image = My.Resources.button_red
          End If
          e.CellElement.Text = ""
      End If
  End Sub

Thank you for your help.

0
Jack
Telerik team
answered on 23 Aug 2010, 01:56 PM
Hello Roberto Andrade Olivie,

Thank you for writing me back and I am glad to hear that you have found solution for this issue. If you have any other questions, please do not hesitate to contact me.

All the best,
Jack
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Blas
Top achievements
Rank 1
Answers by
Jack
Telerik team
Blas
Top achievements
Rank 1
Share this question
or