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

How to remove values from filter

4 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Praveen
Top achievements
Rank 1
Praveen asked on 24 Nov 2015, 04:49 AM

Hi, 

I'm using a RadGridView which has many columns of type GridViewComboBoxColumn. "IsFilteringAllowed" is set to true. I've some columns which is binded to enums. Hence, when the grid in rendered, its picking the filter options from the enum. Since its nullable enum, the filter option contains "null" and blank entry. I'm trying to remove them. I'd searched and explored a lot in internet including Telerik forums, but didn't find the right way yet. 

Could someone throw some light in the right direction to solve this?

public enum TestEnum
    {
        One = 0,
        Two,
        Three,
    }
....
....
private TestEnum? _objTest;
public TestEnum? sampleTest
        {
            get
            {
                return _objTest;
            }
        }
...
...
<telerik:GridViewComboBoxColumn x:Name="TESTING"     DataMemberBinding="{Binding sampleTest}"        Header="{Binding Path=Sequence,  Source={StaticResource DCTResources}}" TextAlignment="Center" Width="28" IsReadOnly="True" IsVisible="{Binding IsVisible}" ShowDistinctFilters="True" />
...
...
Resulting filter contains values: (blank), null, One, Two, Three
 

 

Regards,

Praveen.

4 Answers, 1 is accepted

Sort by
0
Praveen
Top achievements
Rank 1
answered on 25 Nov 2015, 08:32 AM

Update:

 http://docs.telerik.com/devtools/silverlight/controls/radgridview/filtering/how-to/howto-customize-the-default-field-filter-editor.html

As per above article, i was able to hook up to the filter values (in fact its called filter editor) and view the list. BUT, when we try to remove the items which we wanted to remove, we get exception "Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead"

 The reason being we are trying to modify the items which is bound to UI, as explained in below article. 

 http://stackoverflow.com/questions/11089104/operation-is-not-valid-while-itemssource-is-in-use-access-and-modify-elements-w

 

It seems its not possible to achieve the desired result. 

 

Just curious, is there a way to bind a grid column to two properties - one for actual item source to display values, and another one for binding to filter editor? Currently for filter editor, it picks the values from the same property which we had bound for item source. 

 

Regards,

Praveen

 

 

 

0
Stefan
Telerik team
answered on 26 Nov 2015, 03:41 PM
Hello Praveen,

I am afraid that as you have already found, the requirement from your first post would not be possible, as the filtering is a data operation and is performed over the underlying collection bound to the ItemsSource property of RadGridView.

As to your second requirement, there is a built-in mechanism that you can benefit from - the FilterMemberPath property of GridViewDataColumn. Basically, through it you can point to a property different from the displayed one.

Can you please give it a try and let me know how it goes?

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Praveen
Top achievements
Rank 1
answered on 01 Dec 2015, 09:06 AM

Hi Stefan, 

Thanks for your reply. 

We got held up with another task. I will post my results once I try the above suggestion. 

Regards,

Praveen

0
Stefan
Telerik team
answered on 04 Dec 2015, 08:33 AM
Hi Praveen,

Feel free to write back when you have an update on the suggested approach. I will be happy to help in case you need further assistance.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Praveen
Top achievements
Rank 1
Answers by
Praveen
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or