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.
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