We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Changing filter on one SfDataGrid changes the filter on another SfDataGrid on the same form

I am new to using SyncFusion controls and do not understand why this happens.  If I have more than one SfDataGrid on the same form, then changing the filter on one grid also changes the filter on the other grid even though I have not created any code to link them.  I want the grids to use the same data source, but not affect each other's filter or sorting.  I am using VS2019 and SF  To re-create the problem just create a new winform project and add an sfDataGrid to Form1.  Set AllowFiltering to True.  Copy and paste the grid so that there are now two grids named sfDataGrid1 and sfDataGrid2.  Then add the following code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sfDataGridProblem
    public partial class Form1 : Form
        private DataTable dt = new DataTable();

        public Form1()

        private void Form1_Load(object sender, EventArgs e)
            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Selected", typeof(bool));
            dt.Rows.Add(new object[] { 1, false });
            dt.Rows.Add(new object[] { 2, true });
            dt.Rows.Add(new object[] { 3, false });
            dt.Rows.Add(new object[] { 4, true });
            dt.Rows.Add(new object[] { 5, false });

            sfDataGrid1.DataSource = dt;
            sfDataGrid2.DataSource = dt;

3 Replies

FP Farjana Parveen Ayubb Syncfusion Team August 23, 2019 09:33 AM UTC

Hi Larry, 
Thank you for using Syncfusion controls. 
SfDataGrid performs the data related operations such as filtering and sorting for DataTable DataSource with the DataTable's RowFilter and Sort properties. So, its obvious that if you perform any operation in datagrid, underlying DataTable will also be updated since we updated the RowFilter & Sort properties.  
Hence, if you bind the same DataTable to 2 different SfDataGrid, another datagrid will get update. This is the behavior of SfDataGrid with DataTable.  
Meanwhile, you can overcome this scenario by converting the DataTable to dynamic object collection.  
Please refer the below code example 
List<dynamic> dynamicDt = dt.ToDynamic(); 
sfDataGrid.DataSource = dynamicDt; 
sfDataGrid1.DataSource = dynamicDt; 
Please let us know if you need any further details on this. 
Farjana Parveen A 

LB Larry Byrd August 23, 2019 09:56 PM UTC

Thank you for your response.

FP Farjana Parveen Ayubb Syncfusion Team August 26, 2019 05:37 AM UTC

Hi Larry, 
Thanks for the update. 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
Farjana Parveen A  

Live Chat Icon For mobile
Up arrow icon