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 datagrid height to auto?

Thread ID:

Created:

Updated:

Platform:

Replies:

131927 Aug 3,2017 02:46 PM UTC Aug 4,2017 11:21 AM UTC Xamarin.Forms 1
loading
Tags: SfDataGrid
Gangatharan Baskaran
Asked On August 3, 2017 02:46 PM UTC

How can I set the height of the datagrid as auto? I want the datagrid height to follow the contents of the grid. I don't want scrolling on my grid. I want it to generate the grid with height according to the contents of the gird.

Indhumathy Malayappan [Syncfusion]
Replied On August 4, 2017 11:21 AM UTC

Hi Gangatharan Baskaran,

Thank you for contacting Syncfusion Support,

I have checked your query and you can set the height of the datagrid based on the content by using the following way and you can also know the height of the datagrid by multiplying the records count with rowheight and then add th
e header row height to it.

Refer the below codes for your reference,
 
private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e)
{
    var height = (dataGrid.View.Records.Count * dataGrid.RowHeight) + dataGrid.HeaderRowHeight;
 this.SfGrid.HeightRequest = (double)height;
} 

Sample Link:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/DataGridDemo-1621419080

Please note that this method is not effective when you are using QueryRowHeight since each row height varies. Please revert us if you have any other concerns.

Regards,

Indhumathy M

 


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.

Please sign in to access our forum

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

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

;