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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to summarize, adding a row in the end and change the column content font color ?

Thread ID:

Created:

Updated:

Platform:

Replies:

120539 Sep 24,2015 02:17 PM UTC Sep 25,2015 09:59 AM UTC Xamarin.iOS 1
loading
Tags: SfDataGrid
SAGE
Asked On September 24, 2015 02:17 PM UTC

Hi! I'm Raphael, and I'm using sfDataGrid for Xamarin.iOS unified.

I have a datagrid with two columns: "Name" and "Total".

Example:

 -------------   ----------
|    Name     |    Total   |
 -------------   ----------
|  Raphael    |    200,00 |
|  Carlos       |    150,00 |
|  David        |      20,00 |
 -------------   ----------


I need to put an "extra row" with the total value

Something like


 -------------   -----------
|    Name     |    Total    |
 -------------   -----------
|  Raphael    |    200,00  |
|  Carlos       |    150,00  |
|  David        |      20,00  |
|  TOTAL     |     (SUM) |
 -------------   -----------

And this "total row", just for the "total column" (not the "name column) I need to change the font color for green (or red in case of negative values) in execution time.

How can I do this two things ?

Can you help me?

Thanks




Harikrishnan N [Syncfusion]
Replied On September 25, 2015 09:59 AM UTC

Hi Raphael,

Thank you for using Syncfusion Products.

In SfDataGrid, you can change the font color of the text inside the GridCell in execution time by customizing the GridCell. You can add views inside the GridCell and customize the text color in the LayoutSubViews from the sample based on your requirement. Please refer the below code example to know about “how to customize a GridCell”.



GridTextColumn customColumn = new GridTextColumn();

customColumn.UserCellType = typeof(CustomCell);

customColumn.MappingName = "CustomColumn";
SfGrid.Columns.Add(customColumn);

public class CustomCell : GridCell

{

            UILabel stocktext;


            public CustomCell ()

            {

                        stocktext = new UILabel ();

                        stocktext.Font = UIFont.SystemFontOfSize (20);

                        this.Add (stocktext);

                        this.CanRenderUnLoad = false;

            }


            protected override void UnLoad ()

            {

                        this.RemoveFromSuperview ();

            }


            public override void LayoutSubviews ()

            {

                        base.LayoutSubviews ();


                        if (Convert.ToDouble (DataColumn.CellValue) < 0) {

            this.stocktext.TextColor = UIColor.Red;

                        } else {

            this.stocktext.TextColor = UIColor.Green;

                        }

                        this.stocktext.Frame = new CoreGraphics.CGRect (Bounds.Left, Bounds.Top, Bounds.Width, Bounds.Height);

       this.stocktext.Font = DataColumn.GridColumn.RecordFont;

        this.stocktext.TextAlignment = UITextAlignment.Right;

                        this.stocktext.Text = DataColumn.CellValue.ToString ();

            }


            protected override void Dispose (bool disposing)

            {

                        if (stocktext != null) {

                                    stocktext.Dispose ();

                                    stocktext = null;

                        }

                        base.Dispose (disposing);

            }
}


For more details about customizing the GridCell in SfDataGrid, please refer the Formatting sample and RenderingDynamicData sample in our Demo samples.

Regarding your query to put an extra row to display the summary information in SfDataGrid:
Currently there is no support for this, however we have already considered this as a feature. A support incident to track the status of this feature has been created under your account. Please log on to our support website to check the further updates.

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

Please let us know if this helps.

Regards,
Harikrishnan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;