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
close icon

data violation and filtering

I am using the IDataErrorInfo to display when a cell has data violation. Is there a way to add a filter to the column to show only those cells with an error?


8 Replies

MA Manikandan Syncfusion Team June 13, 2011 12:01 PM UTC

Hi Mary,

Thanks for using Syncfusion Products.

you cannot add a filter to the column with respect to the data violation condition. However you can achieve this by specifying the filtering condition explicitly, which the same condition you have defined for data violation.

Please refer the following code snippet:

Code Snippet [C#]

Data Violation Condition:

public string this[string columnName]
{
get
{
var result = string.Empty;
if (columnName == "Freight")
{
if (this.Freight.Value < 10)
{
result = "Freight is very low";
}
}
return result;
}

}

Filtering Condition:

void dataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.dataGrid.VisibleColumns["Freight"].Filters.Add(
new Syncfusion.Windows.Data.FilterPredicate()
{
FilterBehavior = Syncfusion.Linq.FilterBehavior.StronglyTyped,
FilterType = Syncfusion.Linq.FilterType.LessThan,
FilterValue = "10",
PredicateType = Syncfusion.Windows.Data.PredicateType.Or
});
}

We have prepared a sample based on this. Please find the sample from the following location.

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Sample-126361468.zip

Please let us know if this helps.

Regards,
Manikandan





MF Mary Fontana June 13, 2011 04:32 PM UTC

Thanks for your sample.

In my application the data provider
has a value, upperLimit, lowerLimit


What if in your example
there are two other columns FreightLower FreightUpper

in public string this[string columnName]

instead of:
if (this.Freight.Value < 10) result = "Freight is very low"

you have
this.Freight.Value < this.FreightLower.Value
|| this.Freight.Value > this.FreightUpper.Value
result = "Freight is not within limits"

How do you set the FilterValue in the FilterPredicate for this?





MA Manikandan Syncfusion Team June 15, 2011 11:23 AM UTC

Hi Mary,

Thanks for your update.

You can achieve your requirement by adding two Filter Predicate. One predicate with lower value as FilterValue and LessThan as FilterType, another predicate with Upper value as FilterValue and GreaterThan as FilterType. For both Filter Predicate the FilterType should be "Or".

We have prepared a sample based on this and you can check it from the following location.

Code Snippet [C#]

this.dataGrid.Loaded += new RoutedEventHandler(dataGrid_Loaded);

void dataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.dataGrid.VisibleColumns["Freight"].Filters.Add(
new Syncfusion.Windows.Data.FilterPredicate()
{
FilterBehavior = Syncfusion.Linq.FilterBehavior.StronglyTyped,
FilterType = Syncfusion.Linq.FilterType.LessThan,
FilterValue = "10",
PredicateType = Syncfusion.Windows.Data.PredicateType.Or
});
this.dataGrid.VisibleColumns["Freight"].Filters.Add(
new Syncfusion.Windows.Data.FilterPredicate()
{
FilterBehavior = Syncfusion.Linq.FilterBehavior.StronglyTyped,
FilterType = Syncfusion.Linq.FilterType.GreaterThan,
FilterValue = "100",
PredicateType = Syncfusion.Windows.Data.PredicateType.Or
});
}

Sample: http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=Sample-656269804.zip

Please let us know if you have any questions.

Regards,
Manikandan




MF Mary Fontana June 17, 2011 07:07 PM UTC

I would like to turn on/off a column filter.

I would like to enable/disable a column filter with a toggle button.
But in the code below even after adding the filter, the filter is not applied.
Is this possible?



private void errorOnly_Click(object sender, RoutedEventArgs e)
{
var vcol = gridControl.VisibleColumns["Freight"];
if (errorsOnlyToggle.IsChecked)
{

vcol.Filters.Add(
new Syncfusion.Windows.Data.FilterPredicate()
{
FilterBehavior = Syncfusion.Linq.FilterBehavior.StronglyTyped,
FilterType = Syncfusion.Linq.FilterType.LessThan,
FilterValue = "10",
PredicateType = Syncfusion.Windows.Data.PredicateType.Or
});
}
else
vcol.Filters.Clear();





RV Ramesh V Syncfusion Team June 20, 2011 09:31 AM UTC

Hi Mary,

Thanks for your update.

We have analysed the stated issue with your sample. And we have modified your sample by clearing the Column filters in the CheckBox checked event.
Please find the modified sample under the following location.

Sample: http://www.syncfusion.com/uploads/redirect.aspx?file=Sample_104e319b.zip&team=testingftp

Please let us know if you need more information.

Regards,
Ramesh




MF Mary Fontana June 24, 2011 03:41 PM UTC

Thank you for your sample.

There is one problem I have been having which also occurs in your sample. When I set the checkbox to filter to show only the rows with errors,
I have to click on a colum in order for the filtering to take place. If I uncheck the column, it does undo the filtering without having to click on on the data grid.

Is there a way to have setting the check box to do the filter without having to click on the grid column?

Thanks again for your help



DM Deenadhayalan M Syncfusion Team June 29, 2011 09:41 AM UTC

Hi Mary,

Sorry for the inconvenience caused.

We are able to reproduce the reported filtering issue. We have fixed this in our latest version 9.2.0.138. Could you please upgrade our products to current version? This will

It can be downloaded under the following location.

http://www.syncfusion.com/support/forums/general/99684/Essential-Studio-2011-Volume-2-Service-Pack-Release-v920138-available-for-download

Please let us know if you have any queries.

Regards,
Deenadhayalan



DM Deenadhayalan M Syncfusion Team June 29, 2011 09:46 AM UTC

Hi Mary,

Please ignore the previous update. Find the below.

We are able to reproduce the reported filtering issue. We have fixed this in our latest version 9.2.0.138. Could you please upgrade our products to current version?

It can be downloaded under the following location.

http://www.syncfusion.com/support/forums/general/99684/Essential-Studio-2011-Volume-2-Service-Pack-Release-v920138-available-for-download

Please let us know if you have any queries.

Regards,
Deenadhayalan




Loader.
Live Chat Icon For mobile
Up arrow icon