The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
ungrouping datagrid
Posted: 20 May 09 7:28 AM
|
Ok. I give up. Looked through every post with the keyword "datagrid" and can't find an answer.
My question is: Once you've set a datagrid to turn on grouping (with the columns GroupIndex property), how do you turn it off?
Depending on the data being displayed on my grid, grouping will need to be turned on or off.
Thanks for the help and thanks for being an amazing resource for guys like me. |
|
|
|
Re: ungrouping datagrid
Posted: 02 Jun 09 4:07 PM
|
Thought someone had posted this up here.....
here's my typical grouping stuff: SET GridRS.ActiveConnection = Nothing SET dgWORK.RECORDSET = GridRS '' The GROUPING of the Header is based on the ITEM in the column, counted from left to right, zero based, visible or invisible. ''' SelectFirstRecordForGrid(DGWORK) dgWORK.Columns.Item(TheGroupIndex).GroupIndex = 1 dgWORK.EXPANDALL
Get a recordset, disconnect it put the recordset into the grid. if you don't do this: dgWORK.Columns.Item(TheGroupIndex).GroupIndex = 1 will the new recordset show up as non grouped? Does setting the grid with a fresh recordset KO the grouping???
Or how about this: dgWORK.Columns.Item(TheGroupIndex).GroupIndex = -1
I thought someone said that worked.
grid.showgrouppanel = FALSE of course.....
|
|
|
|
Re: ungrouping datagrid
Posted: 26 Aug 09 7:36 AM
|
This is awesome, I was about to ask how to expand all of the groups on a groups grid and POW, there's the solution.
I have another question regarding this though...
How do I automatically expand all the grouped nodes when a user drags a column into the "Drag a column header here to group by that item". I can't see any event attached to the grid that would trap this.
Thanks in advance! |
|
|
|
Re: ungrouping datagrid
Posted: 26 Aug 09 11:45 AM
|
Here is a trick:
- Add the Summary Footer to the Grid (and add a field to it (something simple such as a Count). - Add a handler for the GetSummary Event and call in the Grid.ExpandAll from within there
|
|
|
|
Re: ungrouping datagrid
Posted: 26 Aug 09 2:11 PM
|
Genius!
However, this only works when you drag the first grouping column to the top. When you drag another one in, effectively making a group and a sub group, they all collapse back up again. My guess is it doesn't bother recalculating the footer for when the second group is added. I'm on v7.2.2 if that helps.
Any other ideas? |
|
|
|
Re: ungrouping datagrid
Posted: 26 Aug 09 2:52 PM
|
Yeap, I should put more than 2 columns on my test grid.
You could try other events, but not sure if they wil fit your conditions. For instance, you could use the MouseUp event and track each column and their GroupIndex on a String, if there are any changes, ExpandAll
e.g.
Dim colStatus
Sub OnMouseApp.... Dim newColStatus Dim i
for i = 0 to datagrid.columns.count - 1 newColStatus = newColStatus & datagrid.colums.items(i).Caption & ":" & datagrid.colums.items(i).GroupIndex & "|" Next
If colStatus <> newColStatus then datagrid.ExpandAll
colStatus = newColStatus End If End Sub
You are basically creating a long string that has all the columns listed with their group index. e.g. First Name:-1|Last Name:-1|Title:-1|Phone:-1| So, lets say that you do move the Last Name column up to the group area, the Mouse Up fires upon the drop and now you get this string: First Name:-1|Last Name:0|Title:-1|Phone:-1| Since the strings are different, you call ExpandAll. If you then move up Title, now your string will be (assuming that you put title as your second group level): First Name:-1|Last Name:0|Title:1|Phone:-1| If you then move Title to first group level: First Name:-1|Last Name:1|Title:0|Phone:-1|
|
|
|
|