Approach needed for custom dropdownlist in grid row that depends on other inputs after view renders

3 posts, 0 answers
  1. BitShift
    BitShift avatar
    29 posts
    Member since:
    Aug 2014

    Posted 07 Oct Link to this post

    Ok,  Ive been going through the different demos/examples such as this one.  Ive got the demo source code and using it to compare with what im doing.
    http://demos.telerik.com/aspnet-mvc/grid/editing-custom

    We have an existing application that a specific column in question is using an EditorTemplate that defines a dropdownlist and it works fine.  However, it loads a list of items beforehand, so that when the grid renders, the list is available.  This list is independent of the data for the rows or the viewmodel.  Thats fine, but I need to load the dropdownlist after the grid and view have rendered and the user has provided some input via other controls.  Using this input, rows are added to the grid - or rather rows are added to the underlying data, then the grid datasource is reloaded.  So then this new row needs to have the column with the dropdown, be specific to the inputs the user has made.  Each row will have the same dropdownlist for that column, but I cant know what the list will contain UNTIL after the grid and view have rendered and the user has provided input.

    Imagine a customer order and its associated items.  The user will have to provide some additional input before they can start adding items to the order.  The sequence kinda goes like this:
    - User chooses a few selections about the order, CustomerAccount, Shipper, etc...then they hit a button that creates the order
    - Then the user starts adding items to the order (which render in the grid)
    - The items in the grid include a column with the dropdownlist.  Its this list that is dependent upon other data the user has provided and cant be known ahead of time.

     

    The template approach seems to be fine - assuming you know what the list for the dropdown will be beforehand, but not if it must be determined AFTER the grid is rendered.  So Im looking at these ideas, any suggestion would be appreciated:

    (1) Use a datasource for the column with the dropdownlist, then when the user creates the order, now I can determine what the dropdownlist should contain, and it will be the same for each order item in the grid.  I would need to update the column datasource somehow and have it refreshed.

    (2) Continue to use the EditorTemplate, but each time I add an item to the grid, include a collection of items in the viewmodel, which I use to filter the list in the EditorTemplate

     

    Suggestions?

     

  2. BitShift
    BitShift avatar
    29 posts
    Member since:
    Aug 2014

    Posted 07 Oct in reply to BitShift Link to this post

    I think possibly I found something to help with this post

    http://www.telerik.com/forums/refresh-dropdownlist-inside-kendo-grid

     

  3. Kendo UI is VS 2017 Ready
  4. BitShift
    BitShift avatar
    29 posts
    Member since:
    Aug 2014

    Posted 07 Oct in reply to BitShift Link to this post

    I made it work! 
    Went back to using the custom editor template, but this time bound the column with the dropdownlist to its own datasource.
    Then, in the Edit event of the grid, I forced the column datasource to update itself.  Bingo

Back to Top