Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
100
XamDataGrid TemplateField Filtering Issues
posted

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?

Persons.zip
Parents
No Data
Reply
  • 16495
    Offline posted

    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.

    PersonsUpdated.zip
Children