SfDataGrid - Cannot add filter

Hi,
I'm using the SfDataGrid inside a TabControlEx. When the SfDataGrid is in the first TabItemEx, I can use the Window.Loaded event to set SfDataGrid.ItemsSource and SfDataGrid.View.Filter.

When i place the SfDataGrid into the second TabItemEx, SfDataGrid.View == null during Windows.Loaded and so i cannot set SfDataGrid.View.Filter.

I have attached a project that illustrates the issue.

Many Thanks,
James.

Attachment: sfdatagridAndTabControlEx_c1d57e47.rar

1 Reply

SR Sivakumar R Syncfusion Team December 4, 2015 08:24 PM UTC

Hi James,

You can set the View.Filter  by handling ItemsSourceChanged event. Find the code snippet and modified sample below,

sfDataGridA.ItemsSourceChanged += sfDataGridA_ItemsSourceChanged;
sfDataGridB.ItemsSourceChanged += sfDataGridB_ItemsSourceChanged;

void sfDataGridB_ItemsSourceChanged(object sender, Syncfusion.UI.Xaml.Grid.GridItemsSourceChangedEventArgs e)

{

    if (sfDataGridB.View != null)

        sfDataGridB.View.Filter = Filter;

}


void sfDataGridA_ItemsSourceChanged(object sender, Syncfusion.UI.Xaml.Grid.GridItemsSourceChangedEventArgs e)

{

    if (sfDataGridA.View != null)

        sfDataGridA.View.Filter = Filter;
}


Sample:
https://www.syncfusion.com/downloads/support/forum/121352/ze/sfdatagridAndTabControlEx-1067328435

Thanks,
Sivakumar

Loader.
Up arrow icon