AD
Administrator
Syncfusion Team
January 18, 2005 06:45 PM UTC
Hi Anthony,
selecting summary rows is not supported with the new record-based selection mechanism.
If you use the old mechanism (when you set TableOptions.AllowSelection = GridSelectionFlags.Any) then you can select any cell, but the old mechanism does not work well with collapse/expand functionality.
In order to loop through selected cells in old selection mechanism you can loop through TableModel.Selections.Ranges
Stefan
AA
Anthony Avella
January 19, 2005 01:55 PM UTC
By commenting out the following line of code - grid.TableOptions.ListBoxSelectionMode = SelectionMode.One;, I''m able to make selections in my grid.
The problem I''m now encountering is when I right click in the selected area to bring up a pop-up menu to allow operations to be performed on the selected rows.
When I right-click, the highlight disappears and the selected range seems gone.
How can I keep my selected range while I right click within the selected range?
>Hi Anthony,
>
>selecting summary rows is not supported with the new record-based selection mechanism.
>
>If you use the old mechanism (when you set TableOptions.AllowSelection = GridSelectionFlags.Any) then you can select any cell, but the old mechanism does not work well with collapse/expand functionality.
>
>In order to loop through selected cells in old selection mechanism you can loop through TableModel.Selections.Ranges
>
>Stefan
>
AD
Administrator
Syncfusion Team
January 19, 2005 03:04 PM UTC
Try setting:
grid.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;
AA
Anthony Avella
January 20, 2005 02:38 PM UTC
Thanks.
I am now at the point where I can highlight a group of rows, both summary and detail rows.
It appears that the selection refers to a section of the grid more than the data in the selected area.
When I highlight a group of summary rows, then expand those rows to view the detail rows, the area of highlight does not increase - instead the detail rows take up at least a portion of the highlight and the remaining summary rows are not highlighted.
When I highlight a range of unexpanded summary rows, is there a way I can access the values in those highlighted summary cells in my code?
When a range is highlighted, I need the actual value (not the column name) the detail rows are grouped by.
Thanks.
>Try setting:
>
>grid.TableModel.Options.SelectCellsMouseButtonsMask = MouseButtons.Left;
>
AD
Administrator
Syncfusion Team
January 21, 2005 12:16 PM UTC
Anthony,
the cell-based selection mechanism has no knowledge about groups, only the underlying cells. It is a pure Grid-based solution. That''s why collapsing and expanding cells is not correctly handled.
In order to acess values for a selected range, you can get the GridRangeInfo and then check the contents of the cells.
GridRangeInfo range = grid.TableModel.Seclections.Ranges.ActiveRange;
if (!range.IsEmpty)
{
for (int r = range.Top; r < range.Bottom; r++)
{
Element el = grid.Table.DisplayElements[r];
if (el is SummaryRow)
{
Group parentGroup = el.ParentGroup;
// now here you can get values from SummaryRow
}
}
}
Stefan
AA
Anthony Avella
January 25, 2005 06:29 PM UTC
How do I get the values that are in the summary cells?
>Anthony,
>
>the cell-based selection mechanism has no knowledge about groups, only the underlying cells. It is a pure Grid-based solution. That''s why collapsing and expanding cells is not correctly handled.
>
>In order to acess values for a selected range, you can get the GridRangeInfo and then check the contents of the cells.
>
>
>GridRangeInfo range = grid.TableModel.Seclections.Ranges.ActiveRange;
>if (!range.IsEmpty)
>{
>for (int r = range.Top; r < range.Bottom; r++)
>{
>Element el = grid.Table.DisplayElements[r];
>if (el is SummaryRow)
>{
>Group parentGroup = el.ParentGroup;
>// now here you can get values from SummaryRow
>
>}
>}
>}
>
>Stefan
>
>
>
AD
Administrator
Syncfusion Team
January 25, 2005 07:06 PM UTC
Anthony,
You could loop through all cells in the row:
int r; // the row
for (int c = 1; c <= grid.TableModel.ColCount; c++)
{
GridTableCellStyleInfo style = (GridTableCellStyleInfo) grid.TableModel[r, c];
if (style.TableCellIdentity.SummaryColumn != null)
Console.WriteLine(style.TableCellIdentity.SummaryColumn.Name + ": " + style.FormattedText);
}
Stefan
AA
Anthony Avella
January 26, 2005 04:50 PM UTC
2 questions:
1- How do I know the summary row I''m in (int r; // the row)?
2- Can I convert the column index in your loop to a column name to be able to identify/retrieve the value of a certain column in the row?
Thanks.
>Anthony,
>
>You could loop through all cells in the row:
>
>int r; // the row
>for (int c = 1; c <= grid.TableModel.ColCount; c++)
>{
>GridTableCellStyleInfo style = (GridTableCellStyleInfo) grid.TableModel[r, c];
>if (style.TableCellIdentity.SummaryColumn != null)
> Console.WriteLine(style.TableCellIdentity.SummaryColumn.Name + ": " + style.FormattedText);
>}
>
>Stefan
>
AD
Administrator
Syncfusion Team
January 26, 2005 06:18 PM UTC
Anthony,
You can get the summary row from r with
GridSummaryRow sumarryRow = grid.Table.DisplayElements[r] as GridSummaryRow;
style.TableCellIdentity.SummaryColumn.Name will give you the name of the summary column.
int r; // r is here the r-value from the for (int r = range.Top; r <= range.Bottom; r++) loop mentioned earlier.
Stefan
AA
Anthony Avella
January 27, 2005 12:11 PM UTC
The Summary Row is comprised of the group by value and 0 or more summary column descriptors. How do I get the value of the group by column?
>Anthony,
>
>You can get the summary row from r with
>
>GridSummaryRow sumarryRow = grid.Table.DisplayElements[r] as GridSummaryRow;
>
>style.TableCellIdentity.SummaryColumn.Name will give you the name of the summary column.
>
>int r; // r is here the r-value from the for (int r = range.Top; r <= range.Bottom; r++) loop mentioned earlier.
>
>Stefan
AD
Administrator
Syncfusion Team
January 27, 2005 05:30 PM UTC
Try
grid.Table.DisplayElements[r].ParentGroup.Category
whereas r is the rowindex of the summaryRow.
Stefan
AA
Anthony Avella
January 27, 2005 06:50 PM UTC
Great. Thanks.
I have a somewhat related question now....
Let''s suppose my grouped grid is only showing part of a dataset (some columns have been filtered out via a dataview).
I''d like to iterate through those rows in my code to retrieve the same value as I am in this discussion. Will the this foreach loop - foreach(Record r in grid.Table.Records) do that for me or will this go through the whole underlying dataset?
If this does go through the whole dataset, how can I just iterate through all of the visible rows in the grid?
I''d like to iterate through all of the VISIBLE summary rows in the grid and get the category as you just showed me.
thx.
>Try
>
>grid.Table.DisplayElements[r].ParentGroup.Category
>
>whereas r is the rowindex of the summaryRow.
>
>Stefan
>
>
AD
Administrator
Syncfusion Team
January 30, 2005 12:05 PM UTC
If you want to get the filtered records, try using this.gridGroupingControl1.Table.FilteredRecords instead of this.gridGroupingControl1.Table.Records.