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

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

4 Answers 457 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Khoa
Top achievements
Rank 1
Khoa asked on 26 Nov 2018, 07:29 PM

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?

 

 

4 Answers, 1 is accepted

Sort by
0
Khoa
Top achievements
Rank 1
answered on 27 Nov 2018, 04:09 PM
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?
0
Dinko | Tech Support Engineer
Telerik team
answered on 29 Nov 2018, 11:38 AM
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.
0
Khoa
Top achievements
Rank 1
answered on 29 Nov 2018, 01:55 PM

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.

0
Dinko | Tech Support Engineer
Telerik team
answered on 04 Dec 2018, 10:57 AM
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.
Tags
ComboBox
Asked by
Khoa
Top achievements
Rank 1
Answers by
Khoa
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or