I have a grid that has one column that needs a drop down list. The values in the list for each row is a subset of larger global list - the exact list is determined by an external control and what is selected in other rows for the same column (no duplicates allowed), and of course there is a separate display value shown from the actual value internally. After digging around these forums for a while, I eventually implemented this by having an UltraDropDown and setting that as the ValueList of the column, and using ColumnFilters on the UltraDropDown to filter down to what that specific row can have.
The problem I'm having is the look-and-feel of the drop down. The drop down looks like another grid. I can set some settings to hide the header, hide the extra columns, etc, but in the end it is still a grid that is being dropped down. Our application is heavily styled, so this drop down is very different than others in the app.
Is there any way to actually make this look like a normal drop down? If not, is there another way to achieve this functionality (the filtered list per cell) without resorting to multiple lists? I know of a way to somewhat mimize the number of lists I need, but don't see another way around it besides the UltraDropDown that has this style issue.
A ValueList should look like a regular dropdown.
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.aspx?ArticleID=7841
Just using a ValueList is how I've done it in other places in the application, but this particular grid needs a filtered list for each cell that comes from a much larger master list. When digging around the forums for this type of functionality, there were basically two options - create a value list for each individual cell, or use an UltraDropDown and use filtering to adjust it when dropped down. The UltraDropDown solution is much cleaner and less memory intensive, especially considering the fact that the list for each cell will be constantly changing as the user changes other cells or some filter criteria outside of the grid. The only problem with using the UltraDropDown is that I'm not sure how to make it look like a normal drop down.
Hi,
There's no magic bullet here to make the DropDown look like a regular ValueList. You will have to set a number of properties.
To start with, you will want to hide all of the columns but one. You would do this by setting the Hidden property on each column to true - except for the DisplayMember column, of course.
You will want to turn off column headers, so you can do that using ColHeadersVisible on the band.
You will probably want to turn off borders between rows, so you would use BorderStyleRow and BorderStyleCell for this and set them to None.
I would recommend doing all of this either in the designer or in the InitializeLayout event of the DropDown.
That should get you most of the way there, I think. Let me know if I missed anything.
I tried all of that, and it did act like a normal drop down for the most part, but it was picking up the styling done for the grid so didn't look anything like a normal drop down. I couldn't turn styling off either because it would still look different than a drop down in other areas. Even ignoring the styling issues, it only superficially looked like a standard dropdown, there were still several differences. I guess I was really looking for a "magic bullet" as you call it - a setting that would turn the grid off on the UltraDropDown and leave me with a simple list while still having the filtering capabilities to keep a single list for the entire grid.
I eventually just did it with value lists. I have one global value list that is assigned to the column, to pick up the display names of all of the values in the grid. Then, in the BeforeEnterEditMode event I assign it a filtered list. In order to make sure memory consumption stays relatively low, I also set the value list of the cell to null in the BeforeCellDeactivate event handler. That way, there is at most two lists active at a time. I don't really like this solution, but it looks like that's where I am.
I, of course, don't know the specifics of your application. But I expect that you probably don't need a ValueList for every cell. You probably have a finite list of values that you need ValueLists for. So what I would do is create a caching mechanism.
Let's say, for example, you have a State field in the grid and you want a ValueList dropdown in another cell that lists the cities. In this case, there is a finite limit of the number of ValueLists you need: 50. Many cells in the grid will have the same State, so there is never a need to create more than 50 ValueLists - you can re-use the same list for any row that has the same State.
So you create a class with a Dictionary whose keys are the ID's of a state and whose values are ValueLists. You add a method to this class that takes a State and returns a ValueList. The code for this method checks the Dictionary to see if the ValueLists already exists. If it does not, you create it and add it to the dictionary so that next time the same State is needed, it will be there.
Okay, that makes sense.
Another option would be to use UltraDropDown and deal with the styling by setting the StyleSetName on the control. That way you could create a StyleSet in your isl specifically for DropDowns and you could style them so that they are more like regular dropdowns, instead of looking like grids.
Of course, if you already have it working with the ValueList, then it's probably not worth it, now.
It's much more complicated than that (of course). Lets say I have a grid with a few rows, and a global list of 5 entries (A, B, C, D, E). If I assign A to row 1, then the list for row 2 becomes (B, C, D, E). If I assign B to row 2, then the list for row 3 is (C, D, E). If I now go back to row 1 and hit the drop down, I should now see the list (A, C, D, E). A is available for row 1 because that is where it was previously assigned, but B is unavailable since it is assigned in row 2. If I change the value in row 1 to C, then the list that row 2 and 3 see have changed again.
This is further complicated because the filter is also based on the values of other columns in the same row, and there are other filter settings that exist outside of the grid in the dialog. This all makes it so that when you pull down the drop down for a row, the list may be different than the last time it was shown. The dialog also has the ability to add to the global list, which can obvioulsy also change the local list. In the application, the global list is very large (200+), but by the time all of the filters are in play, the list will only have maybe 8-10 values.
All of this complication is why UltraDropDown worked so well (except for the look-and-feel) - it was very simple to take all of that into account just by having a custom column filter.