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.

How to set right margin in the Header in SfDataGrid?

 

 

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

 

               

Article ID: Published Date: Last Revised Date: Platform: Control:
6901 05/24/2016 01/11/2017 Xamarin.iOS SfDataGrid
Tags:
Did you find this information helpful?
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.
Add Comment
You must log in to leave a comment

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.