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

MVVM Datasource-driven Dropdown in Grid's Pop-up Editor

2 Answers 113 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 23 Jul 2013, 12:20 AM
Hello,

I have the case where some of my editable data elements must be chosen from a drop-down list whose options are driven by external data. I have tried many different variations at accomplishing this with MVVM and have so far been unsuccessful. I've gotten edit and delete to work, as this simplified fiddle shows:

http://jsfiddle.net/D2maN/22/

but am stuck at the creation of new records. The problem is, I have no prior knowledge of the data in the dropdown so cannot hard-code default values in the schema. What I tried in that fiddle is creating a temporary, dummy default value to avoid the error, but now the problem is that if the user clicks "Add new record", and then just clicks "Update" right away (without changing the combobox), that dummy default gets saved (which in the real world breaks my application server-side because it's an invalid choice).

I have a lot of control over most aspects of this, so am open to any recommended approach for handling this case. I've looked through all of the demos a number of times but have been unable to locate one with this situation. The most promising theory I've though of so far is trying to find an event that I can use to programatically select the first element of the combobox in such a way as to actually update the viewModel right when the popup opens, but I can't seem to figure out how to do that. But, again, any way that works is fine with me...

Any thoughts or help would be greatly appreciated.

Thanks,
--Dan

2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Jul 2013, 01:12 PM
Hello Dan,

I can suggest you to use the edit event of the Grid the following way:

http://jsfiddle.net/D2maN/23/

I hope this helps.

Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dan
Top achievements
Rank 1
answered on 24 Jul 2013, 05:31 PM
Great. Thanks Petur.
Tags
MVVM
Asked by
Dan
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Dan
Top achievements
Rank 1
Share this question
or