Hi,
I need to have multiple buttons inside a single grid cell. The buttons will be used to show a particular row in a child band. Taking an Order/Order lines example. I want the Orders table row to have a unbound column that will be dynamically filled with horizontal buttons for each Order Line row in that order. Looking at the image below, each of the 3 rows in the Order Lines column is a button that when pressed will expand the Order Lines child band that is filtered to show only that particular order line that was selected.
What I don't know how to do is:
Is this design even possible using existing editor controls?
Thanks
Mike Saltzman provides some information about putting multiple buttons in a cell in this post:http://forums.infragistics.com/forums/p/1291/11787.aspx#11787
If you want to show different buttons in different cells in the same column, then you'll need to set a individual edtior control for each cell, rather than just one for the column. In an ideal situation, if you have a finite number of button combinations (for instance, you'll only ever show no, one, two, or three buttons), then you can create a single editor control for each such combination, and connect your cells to those editors on an as-needed basis.
Off the top of my head, I don't recall whether it's an event on the grid or an event on the editor that's raised when you click these editor buttons.
The simplest option would be to use a column for each button.
But if that's no good and you really must have multiple buttons in a cell with no text, then you can acheive this with a CreationFilter. It would be a bit tricky, as you would have to derive your own ButtonUIElement class and replace the existing elements in the cell with a series of buttons that are somehow identified and fire events you can handle.
If yuo want to try that, I recommend that you check the Infragistics Knowledge Base for articles and samples on CreationFilters. Also, get the Infragistics UIElementViewer Utility. This utility is a big help when working with UIElements.
I threw together a quick sample of doing this with a CreationFilter.
Mike,
How do I go about dynamically controlling the number of boxes based on a child collection? I'm pretty sure I need to do it in the InitializeRow event and access the child collection and loop the button creation code.
No, you woud still do this in a CreationFilter. If you look at the code, it's just arbitrarily creating 3 buttons per cell. But there's no reason it has to be limited to 3. You can create as many buttons are you want and arrange them however you want.
The code in the CreationFilter gets a reference to the cell object. So if you want to get the child rows, you can easily do that using cell.Row.ChildBands["child band key"].Rows.
One thing you may want to do in the InitializeRow is set the Height of the row, so it has enough room to accomodate the buttons. You will probably also want to set RowSizing (on the Override) to Free to allow each row to have a different height. I would do this in the InitializeLayout.
Everything works great Mike, but now when I'm trying to style the button it tells me that ButtonStyle is read-only.
buttonElement1.ButtonStyle = UIElementButtonStyle.Borderless;
It is read-only. But you can override it on the derived button element class. :)