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

Grid Selected row cells are reorder when scrolling the vertical Scrollbar.

3 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
karthikeyan
Top achievements
Rank 1
karthikeyan asked on 02 Jun 2017, 10:38 AM

Hi,

    In my grid the grid cells are 19 but if in UI only 14 are showing due to window size due to that grid cells are showing 9 when I scroll grid vertically then the cells are dynamically changed based on the UI. The issue is based on 'Qualification' column cell value one of the grid column button will load another dialog.

Initially loading it passes the correct cell value but when I scroll then it's getting error because of the Invalid column. Here are the code I used, In the following code I used to get the value by using cell(5), I need to get the column cells value dynamically.

 

Private Sub btnTimeKeepingJobMapping_Click(sender As System.Object, e As System.EventArgs)
'EnqueueWaitCursor()
DataGridBase.GridView.SelectedItem = DirectCast(sender, Button).DataContext

'Dim itemValue As String = dataItem("Qualification").Text
Dim odlg_TimeKeepingJobMapping As New dlg_TimeKeepingJobMapping
Dim oGridViewCellBase As GridViewCellBase = DirectCast(DirectCast(DirectCast(DirectCast(sender, Button).Parent, StackPanel).Parent, GridViewCell).ParentRow, TreeListViewRow).Cells(5)
If (CInt(sender.tag) > 0) Then
odlg_TimeKeepingJobMapping = New dlg_TimeKeepingJobMapping(CInt(sender.tag), DirectCast(DirectCast(oGridViewCellBase.Content, LookupElement).ComboBox.SelectedItem, Object).Qualification)
End If

AddHandler odlg_TimeKeepingJobMapping.Closed, AddressOf odlg_TimeKeepingJobMapping_Closed
odlg_TimeKeepingJobMapping.ShowDialog()
End Sub

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 05 Jun 2017, 09:09 AM
Hi,

This is because of the virtualized nature of RadGridView. When the virtualization of the grid is turned on (which is by default), its elements (the rows/cells) are created when they should be brought into view and they are also reused on scrolling. The recommended approach is to work with the data item. For example, you can get the values of the selected row like so:
private void Button2_Click(object sender, RoutedEventArgs e)
       {
           var name = (this.clubsGrid.SelectedItem as Club).Name;
       }

where Club is the data item behind the row.

I hope this helps.

Regards,
Yoan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
karthikeyan
Top achievements
Rank 1
answered on 05 Jun 2017, 10:40 AM
HI Thanks for the reply but in my code the specific cell values are taken from the other Business level class so for me your code won't work I already tried this method, it will only work within the class fields.
0
Yoan
Telerik team
answered on 05 Jun 2017, 11:10 AM
Hello,

I am afraid that working with the data items is the only recommended approach. Otherwise, you will have problems which are described in this help article.

Another possible solution is to disable the Virtualization (setting EnableRow/ColumnVirtualization properties to False), but keep in mind that this is highly not recommended since can lead to performance problems.

Regards,
Yoan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
karthikeyan
Top achievements
Rank 1
Answers by
Yoan
Telerik team
karthikeyan
Top achievements
Rank 1
Share this question
or