This is a migrated thread and some comments may be shown as answers.

[Solved] Can I add filtering for a Template column

6 Answers 166 Views
Grid for XAML
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pat
Top achievements
Rank 1
Pat asked on 17 Jul 2013, 01:47 AM
I have a couple of Template columns that I would like to add support for filtering (and sorting on). I cannot see anything that would let me do this.

6 Answers, 1 is accepted

Sort by
0
Ivaylo Gergov
Telerik team
answered on 17 Jul 2013, 03:33 PM
Hi Pat,

Thank you for your interest.

You can enable sorting through the UI on a TemplatedColumn using the DataGridTemplateColumn.SortDescriptor property. You can choose between the PropertySortDescriptor and the DelegateSortDescriptor.
About the Filtering on a TemplatedColumn - it is not supported out-of-the-box, but I would like to suggest a possible solution for implementing it with a few steps:
  1. In order to show the FilterGlyph button in the header of the TemplatedColumn, you will need to define the DataGridTemplateColumn.HeaderStyle and change its Template. Then you can use the default template of the DataGridColumnHeader and set the Visibility property of the InlineButton with x:Name="PART_FilterButton"  to True.
  2. Create a custom IFilterControl that will suits the current scenario. You can see how to achieve this in the following article - http://www.telerik.com/help/windows-8-xaml/datagrid-filtering-howto-createcustomfilteringcontrol.html.
  3. Create a custom implementation of the FilterButtonTap command and set the appropriate FilterControl when the user taps on the templated column.
Also, for your convenience, I have attached a project that fits this scenario.

I hope this helps. Please, let us know should you have any questions.

 

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.


0
Pat
Top achievements
Rank 1
answered on 18 Jul 2013, 04:15 PM
Thanks very much for the example. That got the filtering enabled and responding. I was wondering if you could point me at the XAML for the two part filtering form.
0
Ivaylo Gergov
Telerik team
answered on 19 Jul 2013, 11:14 AM
Hi Pat,

You can find the generic XAML code of the RadDataGrid in the following folder on your local machine - \Program Files (x86)\Telerik\RadControls for Windows 8 XAML Qx 201x\Binaries\Grid\Telerik.UI.Xaml.Grid\Themes.

 

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pat
Top achievements
Rank 1
answered on 23 Jul 2013, 03:07 PM
I have a DataGridTemplateColumn whose content template is a StackPanel which has 3 embedded TextBlocks.

I have created a class 

    class RankFilterDescriptor : NumericalFilterDescriptor
    {
        protected override bool PassesFilterOverride(object itemValue)
        {
            if (itemValue != "")
            {
            }
            return true;
        }
    }

to allow me to check if the row value matches the descriptor. I can see how to obtain the operate and the matching value from the descriptor. I cannot see how to obtain the object for the row to effect the actual matching.

The itemValue object always seems to be an empty string.
0
Ivaylo Gergov
Telerik team
answered on 26 Jul 2013, 06:38 AM
Hi Pat,

Thank you for getting back to us.

I have attached a project that demonstrates the described scenario. On our side, the itemValue receives the correct values of the assigned property. Could you please, check if this is working your side too? If yes, could you please modify it, in order to reproduce the issue?
As a note, I would like to clarify that in this case the itemValue will receive the value of the assigned property through the RankFilterDescriptor.PropertyName property. If your desire is to receive the whole row(i.e. the business object) you can use DelegateFilterDescriptor instead.

I am looking forward to your reply.

 

Regards,
Ivaylo Gergov
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Pat
Top achievements
Rank 1
answered on 27 Jul 2013, 05:16 PM

I discovered the mistake I was making. In my RankFilterControl class in the BuildDescriptor override when I was creating the RankFilterDescriptor I as not setting the PropertyName to the correct property which returns the numeric Rank value property.

The itemValue now has the correct values and the filtering is working as expected.

Tags
Grid for XAML
Asked by
Pat
Top achievements
Rank 1
Answers by
Ivaylo Gergov
Telerik team
Pat
Top achievements
Rank 1
Share this question
or