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

[SfDataPager] Calculate optimal PageSize so that there is no vertical scrollbar based on rotation?

Thread ID:

Created:

Updated:

Platform:

Replies:

142120 Jan 21,2019 09:49 AM UTC Feb 27,2019 05:55 AM UTC Xamarin.Forms 10
loading
Tags: SfDataGrid
André Ziegler
Asked On January 21, 2019 09:49 AM UTC

How can I calculate the optimal PageSize for the datapager so that there is no vertical scrollbar!!!! based on device rotation (more entries in portrait compared to landscape)?

VS2017 15.9.5
Xamarin.Forms 3.4.0.1009999
Syncfusion.Xamarin.SfDataGrid 16.4.0.42
.net standard 2.0 lib as shared project
Windows 10 1709 (UWP app MinVersion 16299/Target: 17763 with Microsoft.NETCore.UniversalWindowsPlatform Version 6.1.9)

Subburaj Pandian Veluchamy [Syncfusion]
Replied On January 23, 2019 10:50 AM UTC

Hi Andre, 
  
Thank you for contacting Syncfusion support. 
  
We have checked query “Optimal way to calculate page size of the DataPager based on device orientation”, it can be achieved.  Page size can be calculated based on datagrid height, please refer the following code example for the same. 
 
[C#] 
protected override void OnSizeAllocated(double width, double height) 
{ 
    base.OnSizeAllocated(width, height); 
    if (this.screenWidth != width && dataGrid.Width>0 || this.screenHeight != height && dataGrid.Height>0) 
    { 
        // Update page size when device orientation is changed 
        this.screenWidth = width; 
        this.screenHeight = height; 
        dataPager.PageSize= this.SetPageSize(); 
        dataPager.ForceLayout(); 
    } 
} 
  
private int SetPageSize() 
{ 
    return (int)((dataGrid.Height - (dataGrid.GetRowHeight(dataGrid.GetHeaderIndex()) - dataGrid.Padding.Top - dataGrid.Padding.Bottom)) / dataGrid.RowHeight); 
} 
  
We have prepared a sample based on your requirement, you can download the same from the following link. 
  
  
We hope this helps. Please let us know, if you have any concern. 
  
Regards,
Subburaj Pandian V  


André Ziegler
Replied On January 23, 2019 02:06 PM UTC

Hi

I tried your demo, but I can't compile it in VS2017 15.9.5. When I add your function to my app I get the error message that GetRowHeight is not found as extension methode for SfDataGrid.

kind regards
André

André Ziegler
Replied On January 24, 2019 10:00 AM UTC

Hi,

I've added using statement

using Syncfusion.SfDataGrid.XForms;
using Syncfusion.SfDataGrid.XForms.DataPager;




and now it works.

But I forget that my sfdatagrid is inside a normal grid for layout (4 rows, grid is in 1)

<xForms:SfDataGrid x:Name="dataGrid" Grid.Row="1" Grid.Column="0" AutoGeneratingColumn="dataGrid_AutoGeneratingColumn"
                                   AutoGenerateColumns="true"
                                   ColumnSizer="Auto"
                                   NavigationMode="Cell"
                                   SelectionMode="Single"
                                   VerticalOverScrollMode="None">


and with the code I get a value which still causes scrollbar.

Jagadeesan Pichaimuthu [Syncfusion]
Replied On January 24, 2019 11:28 AM UTC

Hi Andre, 

Thanks for your update. 

We have checked your query and we have prepared the sample with Xamarin.Forms 3.4, Syncfusion.Xamarin.SfDataGrid 16.4.0.42 and .net standard 2.0 and tested the sample in VS15.9.5. But we are not able to reproduce the reported “GetRowHeight is not found as extension method for SfDataGrid” issue. We have attached the sample for your reference and you can download the same from the below link. If still the issue reproduced from your side, please modify the attached sample and revert us. It will help us to provide the better solution. 


Regards, 
Jagadeesan

André Ziegler
Replied On January 24, 2019 03:40 PM UTC

Hi Andre, 

Thanks for your update. 

We have checked your query and we have prepared the sample with Xamarin.Forms 3.4, Syncfusion.Xamarin.SfDataGrid 16.4.0.42 and .net standard 2.0 and tested the sample in VS15.9.5. But we are not able to reproduce the reported “GetRowHeight is not found as extension method for SfDataGrid” issue. We have attached the sample for your reference and you can download the same from the below link. If still the issue reproduced from your side, please modify the attached sample and revert us. It will help us to provide the better solution. 


Regards, 
Jagadeesan

Hi Jagadeesan,

as I said it works now and I can compile it. But I still have scrollbar, because I have the datagrid inside a nornal grid (grid has 4 rows and I put the datagrid in row 1, the sfdatapager in row 2 and in row 3 I have buttons to to some actions with the sellected row/cell)

André

Arulraj A [Syncfusion]
Replied On January 25, 2019 12:01 PM UTC

Hi Andre, 
 
Thanks for your updated. 
   
To achieve your requirement, you need to subtract the SfDataPager height  in SfDataGrid height to calculated pagesize of the SfDataPager. So that the vertical scroll bar will not appear in the view. Please refer the following code example for the same.  
 
 
protected override void OnSizeAllocated(double width, double height) 
{ 
    base.OnSizeAllocated(width, height); 
    if (this.screenWidth != width && dataGrid.Width > 0 || this.screenHeight != height && dataGrid.Height > 0) 
    { 
        this.screenWidth = width; 
        this.screenHeight = height; 
        dataPager.PageSize = this.SetPageSize(); 
        dataPager.ForceLayout(); 
    } 
} 
 
private int SetPageSize() 
{ 
    return (int)((dataGrid.Height - (dataGrid.GetRowHeight(dataGrid.GetHeaderIndex()) - dataGrid.Padding.Top - dataGrid.Padding.Bottom)- dataPager.Height) / dataGrid.RowHeight); 
} 
 
 
We have prepared the sample based on your requirement and attached for your reference. You can download the same from the below link. 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Arulraj A 


André Ziegler
Replied On February 22, 2019 11:11 AM UTC

Thanks for the reply,

it works fine for 1st view of a page, when I return back the SetPageSize returns different values, because

dataGrid.GetRowHeight(dataGrid.GetHeaderIndex())


returns 2 different values.

On 1st call it return 20 and when I open a new page, navigate back it return 35.5 where all other data are the same:

dataGrid.Height = 615
this.screenWidth = 1663
this.screenHeight = 838

So what is dataGrid.GetRowHeight(dataGrid.GetHeaderIndex()) doing?

André

Pradeep Kumar Balakrishnan [Syncfusion]
Replied On February 25, 2019 06:13 PM UTC

Hi André, 
 
Thank you for the update. 
 
We have checked the reported issue “GetRowHeight method is returning different value for header row height while loading and after navigating to another page.” And it was working fine from our side, and we have attached the sample which is used for testing. 
 
 
In case, if you still experience the issue from your side, please modify the attached sample to reproduce the issue from your side so that it will be helpful for us to validate the issue and provide you solution at earlier. 
 
Regards, 
Pradeep Kumar B 


André Ziegler
Replied On February 26, 2019 02:11 PM UTC

Thanks, I made a 2nd call in my code and this was a mistake. Now the function is only called once it works ok so far when I round the value:


(int)Math.Round((dataGrid.Height - (dataGrid.GetRowHeight(dataGrid.GetHeaderIndex()) - dataGrid.Padding.Top - dataGrid.Padding.Bottom) - dataPager.Height) / dataGrid.RowHeight);

André


Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 27, 2019 05:55 AM UTC

Hi André,  
  
Thank you for the update.  
 
We are happy that the given solution has meet your requirement and resolved the issue at your end. 
 
Please let us know, if you need any further assistance. 
 
Regards,
Subburaj Pandian V  
 


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

This page will automatically be redirected to the 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

;