Unable to update source in dropdown binding

0 Answers 46 Views
MVVM Templates
Scott
Top achievements
Rank 1
Scott asked on 27 Apr 2023, 10:50 PM

I'm using template binding to display a list of users.   For each user, we have a yes/no radio button and a drop down.  The options available in the drop down are dependent on the radio button.  If the user picks "yes" in the radio, we give them 4 options in the drop down, if they select no, we give them 2 options.

I created a view model that contains an array of users and for each user I have an array of the available options for the drop down. 

ex. viewModel= [{UserId: 1, RBValue: true, DropDownId: 3, DropDownOpts: [1,2,3,4]}, {UserId: 2, RBValue: false, DropDownId:1, DropDownOpts: [1,2]};

And then in my template I have a select  as such:

<select source: DropDownOpts, value: DropDownId"></select

When the radio is updated, I modify the DropDOwnOpts for that item.   

When the page loads, it works fine.   The appropriate options appear in the dropdown list, but when I modify the DropDownOpts in the viewmodel, I can see the update in the console, but the options do not change.

Am I missing something obvious here?  Or is this not possible (I'm sure I can do it via js, but would rather not).

Thanks for any help.

Scott
Top achievements
Rank 1
commented on 27 Apr 2023, 11:16 PM

Just to further update this, if I rebind the view model it does work; but if there is a way to do this without rebinding it, that would be even better.
Nikolay
Telerik team
commented on 02 May 2023, 02:48 PM

Hi Scott,

Are you using the Kendo UI DropDownList and the RadioButton? Could you please share the declarations and the binding logic?

Below I am posing some important notes on the MVVM pattern:

Regards,

Nikolay

No answers yet. Maybe you can help?

Tags
MVVM Templates
Asked by
Scott
Top achievements
Rank 1
Share this question
or