Custom filter editor with unbound filter

7 posts, 1 answers
  1. Dan Foster
    Dan Foster avatar
    21 posts
    Member since:
    Jun 2010

    Posted 22 Mar 2011 Link to this post

    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

  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Mar 2011 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dan Foster
    Dan Foster avatar
    21 posts
    Member since:
    Jun 2010

    Posted 22 Mar 2011 Link to this post

    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[]
  5. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Mar 2011 Link to this post

    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
  6. Dan Foster
    Dan Foster avatar
    21 posts
    Member since:
    Jun 2010

    Posted 22 Mar 2011 Link to this post

    Thats the route I was going down, and seems to work perfectly. Thank you very much
  7. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 12 Feb 2013 Link to this post

    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 ?
  8. Yezdi
    Yezdi avatar
    14 posts
    Member since:
    Feb 2011

    Posted 12 Feb 2013 Link to this post

    This problem is solved. There was a problem in the IsNotifying property of the bindable collection. Thanks
Back to Top
UI for WPF is Visual Studio 2017 Ready