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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set filter value to title window

Thread ID:

Created:

Updated:

Platform:

Replies:

119215 May 23,2015 11:42 AM UTC May 28,2015 06:08 AM UTC WPF 9
loading
Tags: SfDataGrid
Oleg
Asked On May 23, 2015 11:42 AM UTC

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

Saravanan M [Syncfusion]
Replied On 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

Oleg
Replied On 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

Saravanan M [Syncfusion]
Replied On 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


Oleg
Replied On May 26, 2015 07:23 AM UTC

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


Saravanan M [Syncfusion]
Replied On 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: http://help.syncfusion.com/ug/wpf/Documents/overview19.htm

Please refer the below KB link for SfDataGrid,

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


Please let us know if you have any other queries,

Regards,

Saravanan.M



Oleg
Replied On 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;
            }

Saravanan M [Syncfusion]
Replied On 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: http://help.syncfusion.com/ug/wpf/Documents/overridingserializationcontroller.htm

Regards,
Saravanan.M


Oleg
Replied On May 27, 2015 07:15 AM UTC

Thank you, you really helped!

Saranya CJ [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;