HA
haneefm
Syncfusion Team
April 24, 2007 06:50 PM UTC
Hi JP,
If you want to get a column name and it group details when clicked on the cell in a grid, you can use the below code:
private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex) ;
if( style != null )
{
Console.WriteLine( "GroupDetails " + style.TableCellIdentity.DisplayElement.ParentGroup);
if( style.TableCellIdentity.Column != null )
Console.WriteLine("Column Name" + style.TableCellIdentity.Column.Name);
else if( style.TableCellIdentity.SummaryColumn != null)
Console.WriteLine("Column Name" + style.TableCellIdentity.SummaryColumn.Name);
}
}
Best regards,
Haneef
JP
JP
April 24, 2007 08:10 PM UTC
Thanks Haneef,
I think this is exactly what I need. I have two further questions:
1. Givng a group, how to find the grouping criteria? For example, if I have 3 grouping columns, how can I find the values of those three columns for the group?
2. How to align a cell? I ask this because the summary cell has left alignment while the correspoing column has righ alignment because they are numbers. I tried the following code which did not work:
sdBuy.Appearance.SummaryFieldCell.TextAlign = GridTextAlign.Right;
sdBuy here is a GridSummaryColumnDescriptor
Thanks for your time.
>Hi JP,
If you want to get a column name and it group details when clicked on the cell in a grid, you can use the below code:
private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
GridTableCellStyleInfo style = e.TableControl.GetTableViewStyleInfo(e.Inner.RowIndex,e.Inner.ColIndex) ;
if( style != null )
{
Console.WriteLine( "GroupDetails " + style.TableCellIdentity.DisplayElement.ParentGroup);
if( style.TableCellIdentity.Column != null )
Console.WriteLine("Column Name" + style.TableCellIdentity.Column.Name);
else if( style.TableCellIdentity.SummaryColumn != null)
Console.WriteLine("Column Name" + style.TableCellIdentity.SummaryColumn.Name);
}
}
Best regards,
Haneef
JP
JP
April 24, 2007 08:57 PM UTC
Found the answer for my second question. Set
HorizontalAlignment instead of TextAlign.
Still need help for the first question. Thanks.
>Thanks Haneef,
I think this is exactly what I need. I have two further questions:
1. Givng a group, how to find the grouping criteria? For example, if I have 3 grouping columns, how can I find the values of those three columns for the group?
2. How to align a cell? I ask this because the summary cell has left alignment while the correspoing column has righ alignment because they are numbers. I tried the following code which did not work:
sdBuy.Appearance.SummaryFieldCell.TextAlign = GridTextAlign.Right;
sdBuy here is a GridSummaryColumnDescriptor
Thanks for your time.
HA
haneefm
Syncfusion Team
April 24, 2007 10:31 PM UTC
Hi JP,
If you want to get the group category then use the ParentGroup.Category to access it. Here is a code snippet.
style.TableCellIdentity.DisplayElement.ParentGroup.Category
If you want to get record collection from the group then call the ParentGroup.Records property. And then you can use the GetValue/SetValue method to get value from the GridRecord. Here is a code snippet.
foreach(Record rec in style.TableCellIdentity.DisplayElement.ParentGroup.Records)
{
Consle.WriteLine( r.Info); //r.GetValue("ColumnName");
}
Best regards,
Haneef
JP
JP
April 25, 2007 01:31 PM UTC
Thanks. That's exactly what I was looking for.
>Hi JP,
If you want to get the group category then use the ParentGroup.Category to access it. Here is a code snippet.
style.TableCellIdentity.DisplayElement.ParentGroup.Category
If you want to get record collection from the group then call the ParentGroup.Records property. And then you can use the GetValue/SetValue method to get value from the GridRecord. Here is a code snippet.
foreach(Record rec in style.TableCellIdentity.DisplayElement.ParentGroup.Records)
{
Consle.WriteLine( r.Info); //r.GetValue("ColumnName");
}
Best regards,
Haneef