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

Grid data ghosting problems when scrolling

3 Answers 83 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Kristjan Einarsson
Top achievements
Rank 1
Kristjan Einarsson asked on 25 Mar 2013, 04:14 PM
Hi,
When I am using a custom column and am scrolling in the treelistview the data seems to move around.
In the screenshot the data that is zero should not be zero. but there are columns that are zero. If I scroll around allot all columns will end up having the same number.

I am using version: 2013.1.311.40

here is my custom column code

public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)
        {
            Grid cellGrid = cell.Content as Grid;
             
            TextBlock primaryText = new TextBlock(){ TextAlignment = System.Windows.TextAlignment.Right };
            TextBlock compareText = new TextBlock() { TextAlignment = System.Windows.TextAlignment.Right, Foreground = new SolidColorBrush(Color.FromRgb(100, 100, 100))};
 
            if (string.IsNullOrEmpty(this.DataMemberBinding.StringFormat))
            {
                this.ComparedPlanBinding.StringFormat = this.DataFormatString;
                this.DataMemberBinding.StringFormat   = this.DataFormatString;
            }
             
            primaryText.SetBinding(TextBlock.TextProperty, this.DataMemberBinding);
            compareText.SetBinding(TextBlock.TextProperty, ComparedPlanBinding);
 
            if (cellGrid == null)
            {
                cellGrid = new Grid();
                cellGrid.ColumnDefinitions.Add(new ColumnDefinition());
                cellGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(20)});
                cellGrid.ColumnDefinitions.Add(new ColumnDefinition());
                cellGrid.RowDefinitions.Add(new RowDefinition());
 
                cellGrid.Children.Add(primaryText);
                Grid.SetColumn(primaryText, 0);
                Grid.SetRow(primaryText, 0);
 
                cellGrid.Children.Add(compareText);
                Grid.SetColumn(compareText, 2);
                Grid.SetRow(compareText, 0);
            }
            return cellGrid;
        }

This only a problem when I scroll. Can you please advice.

Best regards
Kristján

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 26 Mar 2013, 02:01 PM
Hello,

Since the virtualization of RadGridView is turned on by default, it is not recommended to work with the visual elements and their properties. You can take a look at this article for a reference on UI Virtualization. 

In your code you work with the Cell.Content. Would it be possible for you to avoid using it and rely on the DataMemberBinding only?
 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristjan Einarsson
Top achievements
Rank 1
answered on 26 Mar 2013, 02:33 PM
Hi,
When I disabled the visualization it works.

"In your code you work with the Cell.Content. Would it be possible for you to avoid using it and rely on the DataMemberBinding only?"
Not sure, but I need to have custom cells. Can I accomplish that without doing it the way I'm currently doing ?
0
Dimitrina
Telerik team
answered on 27 Mar 2013, 12:49 PM
Hello,

You can check this help article on how to set a custom content for the cell. 

Kind regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TreeListView
Asked by
Kristjan Einarsson
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Kristjan Einarsson
Top achievements
Rank 1
Share this question
or