I’ve encountered an issue with XamDataGrid when attempting to filter a template field using alternate Binding.
I am trying to Filter a field using another field(which has the real data on which the user will filter on)
In the attached solution, sorting works – however on filtering – the search text keeps disappearing (I think this is due to us changing the recordfilter field to another field at the point before which we apply the pending filter).
I have tried using a converter but that seems to break the sortcomparers as we get the converted value instead of the object.
Filtercomparers when used – don’t get called either
I have included comments in the xaml file. Can you please advise?
Hello,
Thank for your post.
I have been looking into the sample application you have provided and the functionality you are looking for.
I believe in your scenario you can create a new RecordFilter for your Salary field. You can set its Operator and Value properties based on the current RecordFilter in RecordFilterChanged event handler, then you can add this filter to the RecordFilters collection of XamDataGrid.
For example:
if (e.RecordFilter.Field.Name == "SalaryText")
{
foreach (var item in Grid.FieldLayouts[0].RecordFilters)
if (item.FieldName == "Salary")
item.Clear();
}
if ((e.RecordFilter as RecordFilter).Conditions.Count > 0)
RecordFilter salaryFilter = new RecordFilter { FieldName = "Salary" };
ComparisonCondition salaryCondition = new ComparisonCondition(((e.RecordFilter as RecordFilter).Conditions[0] as ComparisonCondition).Operator,
((e.RecordFilter as RecordFilter).Conditions[0] as ComparisonCondition).Value);
salaryFilter.Conditions.Add(salaryCondition);
Grid.FieldLayouts[0].RecordFilters.Add(salaryFilter);
I have modified your sample application in order to show you how you can implement this approach and achieve your scenario.
Please let me know if you require any further assistance regarding this matter.
Hi,
I've just ran your updated solution and whilst the filter works , the sort comparer is now broken as it receives string value rather than the object with which we can perform our sort. Isn't it possible to have both filter and sort comparer work in tandem?
Regards,