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

Custom filter editor with unbound filter

6 Answers 131 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
Dan Foster
Top achievements
Rank 2
Dan Foster asked on 22 Mar 2011, 11:20 AM
I have followed the project at http://www.telerik.com/help/silverlight/raddatafilter-how-to-create-custom-filter-editors.html to create a solution that uses a RadComboBox as a custom filter for some fields in a RadDataFilter.

I have been unable however to get the value selected in the RadComboBox to update the underlying FilterDescription, with the Filter always ending up with 'Status isEqualTo <unset>' after selecting an item in the combo box.

I am sure I have followed the project correctly, and have the SelectedValue of the ComboBox bound to the Value property as below.

<DataTemplate x:Key="ComboBoxEditor">
       <telerik:RadComboBox SelectedValue="{Binding Value, Mode=TwoWay, FallbackValue=null}" MinWidth="100" />
</DataTemplate>


The only difference I can see to the example code is that I am using the RadDataFilter unbound. It is not bound to a DataGrid, I am setting my own ItemPropertyDefinitions and using the resulting FilterDescriptions in other parts of the project. Is there a way to check that the DataTemplate Value is getting set when the RadComboBox value changes, or do I need to force the FilterDescription to update somehow as it is unbound? Finally, if nothing else is there a way to manually set the Value or update the FilterDescription when the ComboBox value changes?

Thanks

6 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Mar 2011, 11:33 AM
Hello Dan Foster,

That is strange indeed, since the example works correctly.

You don't need to do anything besides establishing a Binding between your editor and FilterDescriptor.Value, which you have done according to the code snippet.

Can you try the following. Can you add a dummy IValueConverter that does absolutely nothing and apply it on the Value Binding. Then wait with the debugger in the value converter to see what is going back and forth. Or whether the debugger will stop there at all.

If nothing helps, please open a separate support ticket and attach a dummy sample project that reproduces this behaviour. I will debug it in order to see what is going on.

I am looking forward to hearing from you.

All the best,
Ross
the Telerik team
0
Dan Foster
Top achievements
Rank 2
answered on 22 Mar 2011, 12:15 PM
I put together a project that I thought would have the same problem to send to you, but when I tried it it worked fine.

I now realise what I had done wrong; as opposed to the sample code my EditorTemplateSelector chose the filter control to use based on the type of the ItemPropertyDefiniton rather than the name so it would work without having to specify specific ItemPropertyDefiniton names (as they are not known at design time).

To differentiate a list of possible values to be displayed in a combobox against a simple string to be typed in I used typeof(string[]) for my ItemPropertyDefnition for ones I wanted to use a combox for and checked the IsArray property in my EditorTemplateSelector to see if it should use a combobox or not. This all worked, except I assume it didn't like trying to bind the string returned from the ComboBox to the string[] Value on the ItemPropertyDefiniton (which is obvious really!)

Now I know the problem, I just need to figure out how else to differentiate between wanting to use the normal text input and a combobox instead of setting the type on the ItemPropertyDefinition to string[]
0
Accepted
Rossen Hristov
Telerik team
answered on 22 Mar 2011, 01:08 PM
Hi Dan Foster,

Maybe you can derive from ItemPropertyDefinition, add a new prop that will carry this info, and then fill the filter with a list of these new sub-classes. Then in the TemplateSelector, you will cast to your sub-class, read the relevant information and decide which template to supply.

Just an idea.

All the best,
Ross
the Telerik team
0
Dan Foster
Top achievements
Rank 2
answered on 22 Mar 2011, 01:40 PM
Thats the route I was going down, and seems to work perfectly. Thank you very much
0
Yezdi
Top achievements
Rank 1
answered on 12 Feb 2013, 04:09 PM
Hi,
I am facing the exact issue as the one discussed in this thread. When i create the ItemPropertyDefinition, i am setting the type as string. On the RadEditorCreated method , based on the itemproperty selected, i am calling a service to get the datasource for the combobox. When i see the FiltorDescriptors, the ComboBox selected value is unset for the first time, the reason being the once the data is been bound, the Selection Changed event is not firing for the first time. I conformed this by putting a dummy ValueConveter as you suggested in the thread and i can conform that the event is not firing. If i choose another ItemPropertyDefinition and switch back again to the first ItemPropertyDefinition, the ComboBox selection works. Any idea why it is happening ?
0
Yezdi
Top achievements
Rank 1
answered on 12 Feb 2013, 04:53 PM
This problem is solved. There was a problem in the IsNotifying property of the bindable collection. Thanks
Tags
DataFilter
Asked by
Dan Foster
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Dan Foster
Top achievements
Rank 2
Yezdi
Top achievements
Rank 1
Share this question
or