We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SummaryColumn use different Columns

GGC have 3 columns,I need show SummaryColumn in Col3,but the Col3 sum is Sum(Col1)/Sum(Col2)*100 .
How would I accomplish this? Thanks.


5 Replies

JC Jacky chen July 25, 2008 02:06 AM UTC

And Column 2 is Hidden .

>GGC have 3 columns,I need show SummaryColumn in Col3,but the Col3 sum is Sum(Col1)/Sum(Col2)*100 .
How would I accomplish this? Thanks.





RS Rajarajeswari S Syncfusion Team July 29, 2008 05:26 AM UTC


Hi Jacky,

Thanks for using Syncfusion products.

We can have SummaryRows using SummaryRowDescriptor and SummaryColumnDescriptor with GridGroupingControl. Please refer the below code snippet which illustrates your requirement:

$sfwg:GridSummaryRowDescriptor Name="Sum">
$SummaryColumns>
$sfwg:GridSummaryColumnDescriptor DataMember="Col1" Format="{Sum:#}"
Name="Col1Total" SummaryType="Int32Aggregate" DisplayColumn="Col1">
$/sfwg:GridSummaryColumnDescriptor>
$sfwg:GridSummaryColumnDescriptor DataMember="Col2" Format="{Sum:#}"
Name="Col2Total" SummaryType="Int32Aggregate" >
$/sfwg:GridSummaryColumnDescriptor>
$sfwg:GridSummaryColumnDescriptor Name="Col3AVG" DisplayColumn="Col3" SummaryType="DoubleAggregate">
$/sfwg:GridSummaryColumnDescriptor>
$/SummaryColumns>
$/sfwg:GridSummaryRowDescriptor>
$/SummaryRows>


// finding Average for the column1 and column2.
protected void GridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
switch (e.TableCellIdentity.TableCellType)
{
case GridTableCellType.SummaryFieldCell:
{
if (e.TableCellIdentity.SummaryColumn.Name == "Col1Total")
{
HTot = Convert.ToInt32(e.Style.CellValue);
}
if (e.TableCellIdentity.SummaryColumn.Name == "Col2Total")
{
IDTot = Convert.ToInt32(e.Style.CellValue);
e.Style.CellValue = HTot / IDTot;
}
if (e.TableCellIdentity.SummaryColumn.Name == "Col3AVG")
{
e.Style.CellValue ="" ;
}


break;
}
}
}

Please refer the sample from the belwo link, which illustrates this:

http://www.syncfusion.com/support/user/uploads/Summary_9c2014ae.zip


Please let me know if you have any other concerns.

Regards,
Raji





JC Jacky chen July 31, 2008 08:40 AM UTC

Sorry! I use visual studio 2005 , the sample can not run.



JC Jacky chen July 31, 2008 08:43 AM UTC

the key point is I can't hide col 2.




RS Rajarajeswari S Syncfusion Team August 6, 2008 07:33 PM UTC


Hi Jacky,

Sorry for the delay in getting back to you.

We have implemented a feature to hide a column through client side. Hiding column through server side will remove the column from visible columns collection. Hiding through client side will simply hide from showing, but actually the column will exist. Since your requirement is to use the “column2” values at the same time the “column2” should not be shown(hide), you have to hide it only through client side. Please refer the below code snippet which illustrates hiding column through client side:

$script type="text/javascript">
window.onload =hide;
function hide()
{
var gridObj = GetGridTable( document.getElementById('GridGroupingControl1') );
gridObj.HideColumn(2);
}
$/script>

Please refer the hosted sample as per your requirement, where “Col2” has been hidden:

http://websamples.syncfusion.com/samples/Grid.Web/6.3.0.30/Summary/main.htm

In the above link, the sample is running through VS2005. Could you please have a look at the above? and let us know if this helps you out.

Regards,
Raji



Loader.
Live Chat Icon For mobile
Up arrow icon