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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set right margin in the Header in SfDataGrid?

Platform: Xamarin.iOS |
Control: SfDataGrid |
Published Date: May 24, 2016 |
Last Revised Date: January 11, 2017
Tags: formatting

 

 

In SfDataGrid, when you set TextMargin in GridColumn, it will apply the margin only for the record cells and not the header cells. However, you want to set the TextMargin in header, to override the GridHeaderCellRenderer, and append some spaces to the text of UI Label following a period and make the color of the period appended at the end of the transparent, such that it will be look like text is set with some margin at the right end. Otherwise we include transparent period at the end of the string after the spaces and set the TextMargin based on the record cells.

In following code sample ensure that the text is set with the margin at right end.               

 

Output:

Refer the following screenshot that shows the final outcome on execution of the above code.

 

 

You can download a working sample for this KB from the below link:

Right margin in header

 

               

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Justin
Jan 08, 2017
The signature for GridHeaderCellRenderer.OnInitializeDisplayView seems to have changed in a recent release and does not work in 14.4.0.15.

OnInitializeDisplayView(DataColumnBase dataColumn, UILabel view) is now OnInitializeDisplayView(DataColumnBase dataColumn, UIView uiView)

UILabel parameter has been replaced with UIView parameter.

Do you have an updated solution for the new signature?
Reply
Divakar Subramaniam [Syncfusion]
Jan 11, 2017
Hi Justin,

We have modified both the code as well as the sample. Please ensure it.

Regards,
Divakar.

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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