AD
Administrator
Syncfusion Team
July 12, 2005 01:44 AM UTC
1) If you want to set some text into the row header of the summaryrow, you can use the QueryCellInfo event.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryRowHeaderCell)
{
e.Style.CellType = "Static";
e.Style.Text = "Hello";
}
}
2) You can set the Appearance.AnyCell.HorizontalAlignment property on the summaryrowdescriptor.
GridSummaryRowDescriptor srd = new GridSummaryRowDescriptor("row1", new GridSummaryColumnDescriptor[]{sd});
srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(srd);
IV
Ivan
July 12, 2005 03:02 PM UTC
Thank you so much for the prompt response!
I’m really impressed with the level and professionalism of the support provided!
Is it possible to “split” somehow the first column on the summary row, so it displays the title and the value, without moving the title to the row header?
Thank you again.
AD
Administrator
Syncfusion Team
July 12, 2005 06:52 PM UTC
There is no a real nice way to do this that I am aware of. You can handle QueryCellStyleInfo and if you are under the first column ("Col2" in teh code below, you could pre-pend text to this value.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
//if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryEmptyCell)
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell)
{
{
int i = e.TableCellIdentity.Table.TableDescriptor.ColIndexToField(e.TableCellIdentity.ColIndex);
FieldDescriptor fd = e.TableCellIdentity.Table.TableDescriptor.Fields[i];
if(fd.Name == "Col2")
{
e.Style.Text = "hello " + e.Style.Text;//e.TableCellIdentity.Column.MappingName;
}
}
}
}
IV
Ivan
July 12, 2005 11:32 PM UTC
Thank you again,
But how would I find out what is the value of the summary column, using the above example:
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryTitleCell)
{
//Here I need to determine what //SummaryRow/Column it is
}
}
So ultimately the 1st column of the sammary rows would look like:
-----------------|------
Sum $100.00 |
-----------------|------
Avg $7.5 |
-----------------|------
Count 10 |
-----------------|------
AD
Administrator
Syncfusion Team
July 13, 2005 12:40 AM UTC
Here is a little sample using the code similar to that suggested above to display a couple of summaryrows in the manner you described.
http://www.syncfusion.com/Support/user/uploads/GGC_Summaries_a39e999.zip
IV
Ivan
July 13, 2005 03:34 PM UTC
Thank you for the response,
but this is again not exactly what I''m looking for.
1. It should always display row.SummaryRowDescriptor.Name in the first column. If the first column has no summary defined - it should show just the name, if there is summary defined for the first column, then "Name: "+summaryValue;
2. I t should work with DaTaSource==null,
when only columnDexcriptors are set and there is no data bind to the grid.
Is this possible?
Thank you
AD
Administrator
Syncfusion Team
July 13, 2005 04:20 PM UTC
You can do the same sort of thing checking if the first cell is a GridTableCellType.SummaryEmptyCell.
http://www.syncfusion.com/Support/user/uploads/GGC_Summaries_759a07e7.zip
IV
Ivan
July 13, 2005 05:25 PM UTC
Thank you.
There still 2 problems:
1. If GridSummaryColumnDescriptor created before the DataSource is populated, there is an exception geenerated, please see attached file.
GGC_Summaries_759a07e7_2_9370.zip
2. When columns are moved around by user (drag and drop), in come columns the text is displayed as it should, but in some - if format of the firts column.
Thank you
IV
Ivan
July 13, 2005 05:45 PM UTC
Hi,
Ithink I need to use VisibleColumns collection in order to solve my problems:
if(e.TableCellIdentity.TableCellType == GridTableCellType.SummaryFieldCell)
{
int i = e.TableCellIdentity.Table.TableDescriptor.ColIndexToField(e.TableCellIdentity.ColIndex);
GridVisibleColumnDescriptor fd=e.TableCellIdentity.Table.TableDescriptor.VisibleColumns[i];
if(fd.Name == e.TableCellIdentity.Table.TableDescriptor.VisibleColumns[0].Name)//"Col0")
{
GridSummaryRow row = e.TableCellIdentity.DisplayElement as GridSummaryRow;
string padded = " " + e.Style.Text;
e.Style.Text = row.SummaryRowDescriptor.Name + ": " + padded.Substring(padded.Length - 4, 4);;
}
}
else if( e.TableCellIdentity.TableCellType == GridTableCellType.SummaryEmptyCell)
{
int i = e.TableCellIdentity.Table.TableDescriptor.ColIndexToField(e.TableCellIdentity.ColIndex);
if(i == 0)
{
GridSummaryRow row = e.TableCellIdentity.DisplayElement as GridSummaryRow;
e.Style.Text = row.SummaryRowDescriptor.Name;
}
}
AD
Administrator
Syncfusion Team
July 13, 2005 05:49 PM UTC
When I try to unzip your uploaded file, I get a bad zip file message. I suspect you will have to add another check somewhere to handle this as a special case. Can you rezip it and upload it again?
For the second problem, what steps do I take in the sample I attached to see this problem? Is it a refresh problem (meaning that if you cause the grid to repaint say by minimizing it and then restoring it the problem goes away)? If so, you can try calling grid.Refresh after the columns are moved.
IV
Ivan
July 13, 2005 05:59 PM UTC
Sorry for the file, please try this one:
GGC_Summaries_759a07e7_3_6461.zip
For the second problem - just try to drag the columns around.
I think that both of these problems could be fixed by using:
GridVisibleColumnDescriptor fd=e.TableCellIdentity.Table.TableDescriptor.VisibleColumns[i];
if(fd.Name == e.TableCellIdentity.Table.TableDescriptor.VisibleColumns[0].Name)//"Col0")
{...}
Thank you for your patience and support.
IV
Ivan
July 13, 2005 07:53 PM UTC
Hi,
One more issue:
When the grid is groupped by a column, it looks like that summary rows contain an additional cell - in the expand/collapse column.
Is there a way to prevent drawing text in this cell?
Thank you
AD
Administrator
Syncfusion Team
July 13, 2005 11:40 PM UTC
Here is another QueryCellStyleInfo try that I think handles the problems you described.
http://www.syncfusion.com/Support/user/uploads/GGC_Summaries_f8a2100c.zip
IV
Ivan
July 14, 2005 07:47 PM UTC
Thank you,
That is exactly what I was looking for.