I have a requirement to use a dropdown checkbox list in a grid. Each cell in this column should display the concatenation of the 'name' field of the checked items in its list.
I have done this before with a good deal of tinkering--see the post "Adding Checkbox List As Dropdown From Text Editor In Grid Cell", towards the bottom.
However, now I have available the new Infragistics CheckedListSettings, and am wondering: what is considered the 'best practice' for creating and using DataSources for an UltraCombo editor control set as a checkbox list that is assigned to a grid column? What is the easiest way to use this functionality? Anything to streamline the current approach (which is onerous) would be helpful.
Thanks,
J
Hi J,
I'm not sure I understand the question. The DataSource of the list really doesn't matter all that much. You could use any DataSource you like: A DataTable, DataSet, UltraDataSource, BindingList<T>, List<T>, or any class which implements IList or IBindingList.
When choosing a DataSource for the grid, there are some performance and efficiency concerns, some of which are discussed here:
WinGrid Performance Guide
Wingrid Performance and DataSources - Infragistics Forums
But for the drop down list, there isn't as much of a concern, because it's a flat list with no child bands.
Hey Mike,
As always, thanks for the prompt replies. I'm sorry I wasn't more clear in my original post, but I'm not sure how to ask the question. I'll try and describe the situation more clearly.
Here's what I have: A list of contracts to be displayed in a grid, with certain editable fields (name, active or not, start and end dates, etc.). For each contract, there can be zero to many sources, and the requirement is to display a checkbox dropdown list to allow the user to select/unselect the funding sources on each row.
Ideally, I would love to pull a DataSet with the parent table as the Contracts and the child table as the Sources, but that will just give me child rows instead of checking the boxes in the drop down. My past solution on a similar problem was to turn off child bands and add a DataColumn of type List<T> to the DataTable that acted as the grid DataSource, then to manually check the boxes in each dropdown on the BeforeCellListDropdown grid event (I think that's what it's called). That also required me to iterate through each row's list (during InitializeRow), read the values of the checked items in the list, and concatenate those values for the string value to put in the cell itself.
I guess what I'm asking is this: given this data model, what is the ideal 'way to do it'? What I want is to be able to set the grid DataSource to a DataSet; have the parent DataTable populate the main grid; and instead of the child table creating child rows, somehow have the child table act as the DataSource for the Editor in the dropdown checkbox column--so that when the user clicks the dropdown, the correct rows are checked. Once I type it all out, it sounds like I'm asking for quite a bit.
I'm going to go ahead and try using separate, unrelated DataTables for Contracts and Sources, use InitializeRow to set the cell value for the text, and on BeforeCellListDropDown, query a DataView from the Sources DataTable (using the contract ID from the current row) and set that DataView as the DataSource for the dropdown. I'll let you know how it goes.
Sorry it's been so long since I've been able to come back to this, but I was pulled onto other projects. I am briefly experimenting with creating an UltraDataSource in the code from the data, and using it like you did, but I was hoping you'd expand some on part of your previous post:
Infragistics - Mike Saltzman said:There are a couple of ways you could handle this. One would be to change the type on the FUNDING_SOURCES column object. You could still store a List in it, but since it will be a single object, the BindingManager will treat it like a column.
So do you mean set Band.ColumnsCollection["FUNDING_SOURCES"]. Datatype = object? And then still put the List in that column, but maybe cast it to object first? I'm a but unclear how to proceed with this suggestion.
Thanks again for your time,
Sorry, it looks like there was a typo in my previous post. I mean to say:
"One would be to change the type on the FUNDING_SOURCES column to object."
You can't do this on the grid, you would have to do it on your data object class so that the actual property returns an object.
If you can't do that, then you could create an unbound column in the grid, in which case, you could make it of whatever type you want, including List<T>.
Infragistics - Mike Saltzman said:You can't do this on the grid, you would have to do it on your data object class so that the actual property returns an object.
These are probably stupid questions, but what property do I need to have return an object? Is this for the class T that is in the list?
//dt.Columns.Add("FUNDING_SOURCES", typeof(List<object>));dt.Columns.Add("FUNDING_SOURCES", typeof(object));
Now funding source will be a column in the grid instead of a set of child bands. It still contains a list<object> though. Once I do this, it works fine, except that your checked column is never getting added because you are not hooking InitializeLayout on the Combo until after you have already set the data source. So you need to make sure you hook the event before you set the DataSource on the combo.
I got it to work in the sense that the dropdown properly checks the right rows and the cell itself has the right text; however, I get a data validation error when I try to leave the cell.
I also tried doing the other way you suggested, converting the data over from the cell with the List<int> to the unbound List<object> cell in InitializeRow, then pulling the data back out in BeforeRowUpdate. Same error. I've attached both examples, I'm calling the first attempt the Column method and this second attempt using InitializeRow the Row method.
I'm hoping you can take a look and see what I'm screwing up now. I know this has been a long and time-consuming thread, and I really appreciate your continued help.
Awesome, works! Sorry that took so long.
Thanks again for all the help. Only thing I would say is that your last reply doesn't show up in the thread when I access the thread from Forums --> My discussions --> then the thread.
Your reply *does* show up when I click on the link to it from my e-mail notification. The difference seems to be that your latest reply has the thread located in community.infragistics.com/forums, whereas when I access the thread through My Discussions, it takes me to forums.infragistics.com; this may cause confusion for other users.
Peace,
I took a quick look.I think the problem is that you are setting the Column Style to DropDownList. This style requires that the value of the cell match an item on the list and this case that will never happen. So if I turn off DropDownList style, it seems to work okay, at least in the first sample (DropdownCheckboxTestColumnMethod).