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

Set filter value to title window

Hello! I manually set filter on sfDataGrid. How get the value of the current filter and convert it into a text string?

9 Replies

SM Saravanan M Syncfusion Team May 25, 2015 02:43 PM UTC

Hi Oleg,
Thank you for contacting Syncfusion support,
We have analyzed your query. You can get the Filters from FilterPredicates in particular column. You can set the window title as Filter value of particular column. In this example we have set the window title for EmplyeeArea FilterValue as title. Please refer the below code snippet.
Code snippet[C#]:

void datagrid_Loaded(object sender, RoutedEventArgs e)

{

if(this.datagrid.Columns["EmployeeArea"].FilterPredicates.Count >0)

{

this.Title = this.datagrid.Columns["EmployeeArea"].FilterPredicates[0].FilterValue.ToString();

}

}


We have prepared the sample base on your requirement and you can download it from below location
Sample Location: SfDataGridSample_Filter.zip
Please let us know if you have any other queries,
Regards,
Saravanan.M


OL Oleg May 25, 2015 04:02 PM UTC

Hello! Thanks for the help! I'm trying to install a selective filter, but can not get the correct value of the filter. The sample code is attached.
problem with filter

Attachment: SfDataGridSample_Filter_de0f41db.zip


SM Saravanan M Syncfusion Team May 26, 2015 05:45 AM UTC

Hi Oleg,
Thank you for your update,
We have analyzed your query, By default if you UnChecked one or only few items from FilterPopupItems, we use FilterType to NotEquals of UnCheckItems instead of using Equals of all the CheckedItems for performance of FilterControl. So UnChecked items are added as FilterPredicates. You can overcome this by setting FilterType to Equals in FilterChanging event. Now you will get the Selective FilterValue as you expected. Please refer the below code snippet
Codesnippet[C#]:

void datagrid_FilterChanging(object sender, Syncfusion.UI.Xaml.Grid.GridFilterEventArgs e)
{
.
.
.

e.FilterPredicates.Add(new FilterPredicate()

{

FilterValue = item.ActualValue,

FilterType = FilterType.Equals,

FilterBehavior = FilterBehavior.StronglyTyped,

IsCaseSensitive = true,

PredicateType = PredicateType.And
});
.
.
.



We have modified the sample based on this and you can download it from following location,

Sample Location: SfDataGridSample_Filter_Modified.zip

Please let us know if you have any other queries,

Regards,

Saravanan.M



OL Oleg May 26, 2015 07:23 AM UTC

Thanks, all earned. And another question - how to install a filter on only one column?



SM Saravanan M Syncfusion Team May 26, 2015 05:28 PM UTC

Hi Oleg,

Thanks for your update,

We have analyzed your query. You can achieve your requirement by setting AllowFiltering to Fasle for other columns also you need to set AllowFiltering to True for EmployeeArea column to show the Filter. Please refer the below code snippet.

Code snippet[XAML]:

<Syncfusion:SfDataGrid.Columns>

<Syncfusion:GridTextColumn AllowFiltering="False" MappingName="EmployeeName" />

<Syncfusion:GridTextColumn AllowFiltering="False" MappingName="EmployeeAge" />

<Syncfusion:GridTextColumn AllowFiltering="True" MappingName="EmployeeArea" />

<Syncfusion:GridTextColumn AllowFiltering="False" MappingName="EmployeeGender" />

<Syncfusion:GridTextColumn AllowFiltering="False" MappingName="EmployeeSalary" />

<Syncfusion:GridTextColumn AllowFiltering="False"

MappingName="Rating" />

</Syncfusion:SfDataGrid.Columns>



We have modified the sample based on this and you can download it from following location,

Sample Location: SfDataGridSample_Filter_ForColumn.zip

You can also refer the below documentation link to know more about SfDataGrid,

Documentation Link: https://help.syncfusion.com/wpf/welcome-to-syncfusion-essential-wpf

Please refer the below KB link for SfDataGrid,

KB Link: https://www.syncfusion.com/kb/wpf/sfdatagrid


Please let us know if you have any other queries,

Regards,

Saravanan.M




OL Oleg May 26, 2015 06:23 PM UTC

Thank you. The problem was that I serialized table setting with a filter for all the columns, and when restoring the settings put a filter on all columns. I wrote the code to disable the filter.
 foreach(var col in sfGrid.Columns)
            {
                if (col.MappingName != "Symbol")
                    col.AllowFiltering = false;
            }


SM Saravanan M Syncfusion Team May 27, 2015 05:24 AM UTC

Hi Oleg,
We have analyzed your query . You can achieve your requirement by overriding SerializationController with Custom SerializationController. You can override the RestoreColumnProperties method in CustomSerializationController and this method will call , when you DeSerialize the DataGrid. Here you can disable the Filter based on the MappingName. Please refer the below code snippet to achieve your requirement.
Code snippet[C#]:
this.datagrid.SerializationController = new SerializationControllerExt(this.datagrid);

public class SerializationControllerExt : SerializationController

{

.

.

.

protected override void RestoreColumnProperties(SerializableGridColumn serializableColumn, GridColumn column)

{

if (serializableColumn.MappingName != "EmployeeArea")

serializableColumn.AllowFiltering = false;

base.RestoreColumnProperties(serializableColumn, column);

}

.

.

.
}



We have prepared the sample based on this and you can download it from following location,
Sample Location:SfDataGridSample_Filter_Serialization.zip
You can also refer the below documentation link to know more about overriding SerializationController,
Documentation Link: https://help.syncfusion.com/wpf/welcome-to-syncfusion-essential-wpf

Regards,
Saravanan.M



OL Oleg May 27, 2015 07:15 AM UTC

Thank you, you really helped!


SC Saranya CJ Syncfusion Team May 28, 2015 06:08 AM UTC

Hi Oleg,
 
Thank you for your update. Please let us know if you require any other assistance on this.
 
Regards,
Saranya

Loader.
Live Chat Icon For mobile
Up arrow icon