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

Formatting issue for summery row columns

Hi, I am using grid control in one of my application and also I have a summary row with a field, where
GridSummaryColumnDescriptor.Format = "{Sum}";
GridSummaryColumnDescriptor.SummaryType = Syncfusion.Grouping.SummaryType.DoubleAggregate;
The data in the column is decimal.

The summary row works fine, but I am having trouble to set the format of summery column. While i am trying to limit the decimal value by 2 using F2, it is working only if the cell type is of "Formula Cell".

Please advise.
Thank you
Hareesh


3 Replies

SR Sri Rajan Syncfusion Team February 1, 2008 11:58 PM UTC

Hi Hareesh,

Thank you for your interest in Syncfusion products.

To limit the decimal value by 2 using F2, You need to handle TableControlCurrentCellKeyDown and restrict the decimal value by 2 by setting the format using the code sd.Format = "{Sum: ##.#0}. Please refer the below code for more details.


private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if (e.Inner.KeyCode == Keys.F2)
{
GridSummaryColumnDescriptor sd = new GridSummaryColumnDescriptor();
sd.DataMember = "Col2";
sd.DisplayColumn = "Col2";
sd.Format = "{Sum: ##.#0}";
sd.SummaryType = SummaryType.DoubleAggregate;
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Col2", "Sum :", sd));
sd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left;
}
}


Please refer to the attached sample for more details.
http://websamples.syncfusion.com/samples/Grid.Windows/71465/main.htm

Please let me know if this helps.

Regards,
Srirajan



HB Hareesh Bharadwaj February 4, 2008 03:56 PM UTC

Hi SriRajan

Thank you, for your kind help. We tried that solution here now we are able to limit the summery column value. By setting the following formats we are able to limit the summery column values.
{Sum:##.#0} – Display will be 123.12
{Sum:f2} – Display will be 123.12
{Sum:f3} – Display will be 123.123
{Sum:c3}– Display will be $123.123 etc
But still there are some issues.
When we tried to set the summery row column for “Double Aggregate Type” as D (Decimal type), X (Hexa decimal), T (Truncated) etc then the summery row gets disappeared.
EX {Sum:D}
It will be very much helpful for me if you suggest any solution regarding this.

Regards
Hareesh


>Hi Hareesh,

Thank you for your interest in Syncfusion products.

To limit the decimal value by 2 using F2, You need to handle TableControlCurrentCellKeyDown and restrict the decimal value by 2 by setting the format using the code sd.Format = "{Sum: ##.#0}. Please refer the below code for more details.


private void gridGroupingControl1_TableControlCurrentCellKeyDown(object sender, GridTableControlKeyEventArgs e)
{
if (e.Inner.KeyCode == Keys.F2)
{
GridSummaryColumnDescriptor sd = new GridSummaryColumnDescriptor();
sd.DataMember = "Col2";
sd.DisplayColumn = "Col2";
sd.Format = "{Sum: ##.#0}";
sd.SummaryType = SummaryType.DoubleAggregate;
this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Col2", "Sum :", sd));
sd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Left;
}
}


Please refer to the attached sample for more details.
http://websamples.syncfusion.com/samples/Grid.Windows/71465/main.htm

Please let me know if this helps.

Regards,
Srirajan





SR Sri Rajan Syncfusion Team February 5, 2008 09:31 PM UTC

Hi Hareesh,

Thank your for your continued interest in Syncfusion products.

Please refer to the attached sample, that will help you to set the summery row column for “Double Aggregate Type” as D (Decimal type), X (Hexa decimal), T (Truncated) etc


void gridGroupingControl1_TableControlDrawCellDisplayText(object sender, GridTableControlDrawCellDisplayTextEventArgs e)
{
Element el = this.gridGroupingControl1.Table.DisplayElements[e.Inner.RowIndex];
int col = this.gridGroupingControl1.TableDescriptor.ColIndexToField(e.Inner.ColIndex);
string column = this.gridGroupingControl1.TableDescriptor.Columns[col].Name;
if ((el.Kind == DisplayElementKind.Summary && column == "Col2"))
{

int iSum = Convert.ToInt32(e.Inner.Style.CellValue);
e.Inner.DisplayText = string.Format("{0:x}", iSum);
}
}


Please refer to the attached sample for more details.
http://websamples.syncfusion.com/samples/Grid.Windows/71465/Modified_summary.zip

Please let me know if this helps.

Regards,
Srirajan



Loader.
Live Chat Icon For mobile
Up arrow icon