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.