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

3 posts, 0 answers
  1. Dan
    Dan avatar
    9 posts
    Member since:
    May 2013

    Posted 22 Jul 2013 Link to this post

    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. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 24 Jul 2013 Link to this post

    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!
  3. Dan
    Dan avatar
    9 posts
    Member since:
    May 2013

    Posted 24 Jul 2013 Link to this post

    Great. Thanks Petur.
Back to Top