How to synchronized current item with the actually item value upon Itemssource Update?

5 posts, 0 answers
  1. Khoa
    Khoa avatar
    25 posts
    Member since:
    Sep 2018

    Posted 26 Nov 2018 Link to this post

    Hi,

     

    I'm having some problem with the synchronizing the combobox, when ItemsSource updates.

    When I select an object and the combobox update, the item is perfectly synchronized with the selected objects value.

    My problem is that my application poll new items every 10 sec and update/refresh the itemssource.  I'm using isSynchronizedWithCurrentItem = true and the combobox just set the first item by default, instead of displaying the actual value from the selected object, as before the itemssource updated.

     

    How can I fix this?

     

     

  2. Khoa
    Khoa avatar
    25 posts
    Member since:
    Sep 2018

    Posted 27 Nov 2018 in reply to Khoa Link to this post

    Insteading of emptying the observable collection on each update/refresh of the data from database, I'm not adding or removing into the observeablecollection instead. What I notice is that my observeablecollection is updated, but the combobox GUI doesn't refresh with the item. How can I fix this?
  3. Dinko
    Admin
    Dinko avatar
    951 posts

    Posted 29 Nov 2018 Link to this post

    Hi Khoa,

    I am guessing that this behavior comes from the fact that you are updating the items source with new items. Basically, when you update the source collection with new items the previously selected item container is removed. What I can suggest you try on your side is after the update logic is performed, manually search in the new collection the selected item before the update. If such item exists, set this new item to the SelectedItem property of the RadComboBox.

    Regards,
    Dinko
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Khoa
    Khoa avatar
    25 posts
    Member since:
    Sep 2018

    Posted 29 Nov 2018 in reply to Dinko Link to this post

    Okay, atm I'm adding a new item to the observablecollection with a task that pull down a new item from the database every 10 seconds. If I pull down a new item which does not exist in my observablecollection, then I'm adding it to the ObserveableCollection. 

    When I check my observeable collection getter, I can see that the new item is in the collection, but somehow my GUI doesn't refresh. Why doesn't it? If I manually add through the UI, then it works perfectly.

  5. Dinko
    Admin
    Dinko avatar
    951 posts

    Posted 04 Dec 2018 Link to this post

    Hello Khoa,

    Thank for your additional clarifications.

    I tried to reproduce this behavior on my side but I think I am missing a specific step from your implementation. You can find the test project attached to this reply. In the project, I am adding a new item to the ObservableCollection which the RadComboBox is bound for on every 1 second. You can open the drop down to see the new items. Give this project a try and let me know what I am missing.

    Regards,
    Dinko
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top