Grid Cells not showing correct data in SfDataGrid with Dynamic Columns

Hi

I'm working on Dynamic Columns with SfDataGrid. Original Reference from Here. It use DataGrid.
In both cases, when Virtualization is on and grid is scrolled, grid cells show incorrect datas (data of other cells) in Display mode, but when cell enters edit mode, data is correct.
In DataGrid, with EnableRowVirtualization="False", it displays correctly in both display and edit mode.
In SfDataGrid, I set EnableDataVirtualization to False, it displays incorrect datas (in display mode). But when cell enter edit mode, it shows correct data.



I think it is caused by Data Virtualization. If yes,
     1. How to disable Data Virtualization in SfDataGrid
     2. But I know Data Virtualization is one of the advantages of WPF data grid. So it may not a good idea to disable it at all. Can you kindly suggest how should I achieve this.

If not, please kindly tell me what I am missing here.

Thank in advance.

Attachment: DataGridDynamicColumnsStd_83ae0c38.zip

3 Replies

SJ Sathiyathanam Jeyakumar Syncfusion Team July 9, 2018 12:53 PM UTC

Hi Thar, 
 
Thank you for contacting syncfusion support. 
 
We have analyzed your query and we could reproduce the reported problem “Incorrect data showing when apply scrolling”. The DataVirtualization is not the cause of this “Incorrect data showing”. Whenever you scroll the data in SfDataGrid, the GridCell is not created that is reused so the converter is not getting called. So the previous cell value is maintained in the GridCell. You can overcome this problem by using the below code snippets.  
 
 
Public MainWindow() 
{ 
     InitializeComponent(); 
     this.dataGrid.CellRenderers.Remove("TextBox"); 
     this.dataGrid.CellRenderers.Add("TextBox", new GridCellTextColumnRendererExt()); 
 
} 
 
 
 
public class GridCellTextColumnRendererExt : GridCellTextBoxRenderer 
{ 
         
        public GridCellTextColumnRendererExt() : base() 
        { 
 
        } 
        public override bool CanUpdateBinding(GridColumn column) 
        { 
            return true; 
        } 
} 
   
You can download the sample from the below link. 
 
 
You can disable the DataVirtualization in SfDataGrid by using the below code snippets. 
 
<syncfusion:SfDataGrid x:Name="sfdataGrid" Grid.Row="1" MinHeight="120" MaxHeight="250" Margin="5"  
                               ItemsSource="{Binding Users}"  
                               AllowEditing="True"  
                               AutoGenerateColumns="False"  
                               EnableDataVirtualization="False" 
 
You can get more details about by using the below links. 
 
 
Regards, 
Sathiyathanam 



TH Thar Htwe July 9, 2018 06:14 PM UTC

Oh, Wow....
This solve my problem. Thank you.
You guys are the best. :D


SJ Sathiyathanam Jeyakumar Syncfusion Team July 10, 2018 04:22 AM UTC

Hi Thar, 
Thanks for your update. 
We are happy to hear that the reported problem has been fixed with the given details. Please let us know if you need any further assistance on this. 
Regards, 
Sathiyathanam.

Loader.
Up arrow icon