ComboBox Text for absent values

6 posts, 0 answers
  1. Adam
    Adam avatar
    70 posts
    Member since:
    Jun 2008

    Posted 22 May 2014 Link to this post

    Hey all,

    We are trying to achieve some functionality that represents inactive values. If our SelectedValue gets set to a code that is not present in any of the items, we should display the code in the ComboBox until/unless a users clears or otherwise changes the selection. Currently, there are no events to capture this case that I have found in the ComboBox class so we need some method to enforce this logic.

    Thanks!
    Adam.g
  2. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 26 May 2014 Link to this post

    Hi Adam,

    Could you please share some more details about the exact scenario? How do you select a value which is not present in the ItemsSource? As far as understand the case, you need to insert into the ItemsSource typed items that are not present there? However we have such an example for the AutoCompleteBox in our online Xaml SDK repository which demonstrates how to add new items with a button:
    https://github.com/telerik/xaml-sdk/tree/master/AutoCompleteBox/AddNewItemsWithButton

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Adam
    Adam avatar
    70 posts
    Member since:
    Jun 2008

    Posted 06 Apr 2015 in reply to Kalin Link to this post

    Hi there,

     Sorry for leaving this for so long but I've been thinking about this issue more. Let me elaborate.

    We have a number of combo boxes in the system whose values come from database tables. These tables allow users to inactive rows which may not be used commonly anymore. However, some records inevitably exist that are still linked to these inactive values. Furthermore, currently, we limit the items in these ComboBoxes to only active records. Therefore, there are cases where a previously saved record exists that uses one of these inactive values and upon displaying the record the combo box appears empty. 

     

    So then, we are attempting to find a solution to this issue. My main frustration so far is that it does not appear that the RadComboBox even attempts to select the value in any of the user-accessible overrides/event handlers; no selection changed logic ever hits a breakpoint for ComboBoxes that exhibit this issue. It seems that what needs to occur on our end is for us to be able to identify this occurrence and automatically add an item that corresponds to this saved inactive value. But again, I don't see a way to tie into the control in any way to currently handle that case.

     

    Everything make sense?

    Thanks!

    Adam.g

     

  5. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 08 Apr 2015 Link to this post

    Hello Adam,

    If I understand correctly you need to add an item in the ItemsSource if the SelectedValue becomes value that is not present in the ItemsSouce. If you use MVVM you can easily achieve that if you check the incoming new value in the SelectedValue property setter and if it is not present in the ItemsSource - to create and add new item. Please check the attached sample and let me know if it helps.

    Hope it will work for you.

    Regards,
    Kalin
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Adam
    Adam avatar
    70 posts
    Member since:
    Jun 2008

    Posted 17 Apr 2015 Link to this post

    Thanks for the reply,

     The issue with the sample you provided, and I may not have been clear, is that it's very specific to a particular viewmodel property and collection. I need to push this down to a framework level to intercept when any of our ComboBoxes try to bind to a selected value that is not in their ItemsSource. Does that make sense? So I'm looking for some hook in the control class itself to detect this case. I believe that I've tried overriding the actual SelectedValue dependency property but I don't remember that working. However, something like that would be an example of handling the generic case when the selected value does not exist in the ItemsSource.

     

    Thanks!

    Adam.g

     

  7. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 22 Apr 2015 Link to this post

    Hello Adam,

    Now I understand your scenario. RadComboBox inherits from Selector and this logic is happening behind the scenes. I'm afraid there isn't any event that I can suggest. However at the moment you are setting the ItemsSource and the SelectedValue of each ComboBox you can check that SelectedValue actually matches one of the items and if not to create new item and add it to the ItemsSource.

    Hope this helps.

    Regards,
    Kalin
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
DevCraft banner