Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
Useing GroupBy rows to display custom child UI control in 8.2
posted

Using Infragistics 8.2

Hello, All-

I've done some reading on using Creation and Draw Filters, but I need assistance with designing a solution for the following problem:

We have a grid of data with the following datatable schema:

Id, Name, Attribute1, Attribute 2, Score

The Score is a sort of calculated field based on several user-input fields, but none of these inputs are stored in the actual grid.

What we'd like to do is have the GroupBy knobs appear next to each row in the grid, but when the knob is expanded, we inject our own UserControl as the child UIElement that will fill up the space between the rows (while it is exapnded).  This child control will do some calculations and take user input and update the Grid's Score column based on user input.

So, the 2 main questions are:

1) How would I create the grid to show knobs (assuming using GroupBy functionality?) when the grid doesn't have any concept of aggregation that would cause multiple rows to group?  Would I just groupBy ID (ID will be unique) and so the summary row will show the knob and the default expand behavior will be to show the 1 row that has the Group ID?

2) Once I have the GroupBy functionality such that the rows have knobs that expand, would I use a creation filter or draw filter to halt the creation of the child UI elements, and create my own child which is my custom UserControl which takes the user input and modify's the grid's datasource's Score field?

I'm sorry if this is confusing, I'm trying to explain it as straight forward as I can, but if there's anything that i'm leaving out (due to ignorance of the WinGrid's GroupBy capabilities) please let me know and I'll try to fill in the blanks.  I purposely left out where the custom child UserControl will store and modify the User Input data because I do not want to confuse the core question about how to get GroupBy rows to show custom UI controls in their children. I think once i get that behavior nailed down, I can get the code to do the correct work about updating the datasource's Score field.

-Chris

 

Parents
  • 469350
    Offline posted

    Hi Chris,

    I'm having a little trouble understanding the relationship between the UserControl and the score column.

    It sounds to me like you maybe what you want here is not an expandable field in the grid, but rather a dropdown in the score column. This would be very easy to implement using an editor. You could add a dropdown button to the column that drops down a custom control you create and it would be much simpler and easier than trying to insert a control in between rows of the grid.

    If you have to do this in such a way that the usercontrol is visible within the grid in a more permanent way, and it's not just a dropdown, then I think this will be very difficult to achieve.

    But, if you must do that, then what I would probably do is change your DataSource to have a hierarchy. You could use a DataSet, for example, and add a child table with a single column and relate the child table to the parent table which contains the information you are currently displaying in the grid.

    You would add a single child row for each parent row, thus giving you the expansion indicators and a single cell in the grid that can be expanded for each parent row. So this essentially carves out a space for you to put your UserControl and handles all of the expand/collapse functionality for you.

    Then all you have to do is place your control in the cell. This part would be easier if you updated to a newer version of NetAdvantage, because then you could make use of the new ControlContainerEditor. It would save you quite a lot of work.

    But if that's not an option, then what you could do is use a CreationFilter to watch for the creation of the CellUIElement for the child cell and position a control at that point in the grid using the same rect.

    But this is not a trivial implementation. You will need multiple instances of your usercontrol because more than one row of the grid could be expanded at any time. You will also need to handle removing the usercontrols when the rows are hidden or scrolled out of view. I'm not sure how you would handle what happens when a control needs to be partially scrolled out of view, either.

Reply Children