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. Image for the cookie policy date
close icon

data grid row height change per the text

Hi all,

I created a simple datagrid which get the data from a web service works great.
however,
I want the row to to be changed per the text inside the row 

Thanks, 
Best Regards
Barak Rozenfeld

12 Replies

AN Ashok N Syncfusion Team August 24, 2017 06:08 AM UTC

Hi Barak, 
 
Thanks for contacting Syncfusion support. 
 
You can be achieved AutoRowHeight  by handling SfDatagrid.QueryRowHeight event and SfDatagrid.GetRowHeight method. SfDatagrid.QueryRowHeight event returns the row height on demand and SfDatagrid.GetRowHeight method returns the height of the row based on the content. Please refer the below code example  
 
//Hooks QueryRowHeight event in SfDataGrid to set the row height on demand 
dataGrid.QueryRowHeight += DataGrid_QueryRowHeight; 
 
private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    if (e.RowIndex != 0) 
    { 
        //Calculates and sets the height of the row based on its content. 
        e.Height = dataGrid.GetRowHeight(e.RowIndex); 
        e.Handled = true; 
    } 
} 
 
Please refer the below UG link to get more details about AutoRowHeight 
 
 
Regards, 
Ashok 



CC CT CHANG replied to Ashok N November 4, 2017 04:02 PM UTC

Hi Barak, 
 
Thanks for contacting Syncfusion support. 
 
You can be achieved AutoRowHeight  by handling SfDatagrid.QueryRowHeight event and SfDatagrid.GetRowHeight method. SfDatagrid.QueryRowHeight event returns the row height on demand and SfDatagrid.GetRowHeight method returns the height of the row based on the content. Please refer the below code example  
 
//Hooks QueryRowHeight event in SfDataGrid to set the row height on demand 
dataGrid.QueryRowHeight += DataGrid_QueryRowHeight; 
 
private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    if (e.RowIndex != 0) 
    { 
        //Calculates and sets the height of the row based on its content. 
        e.Height = dataGrid.GetRowHeight(e.RowIndex); 
        e.Handled = true; 
    } 
} 
 
Please refer the below UG link to get more details about AutoRowHeight 
 
 
Regards, 
Ashok 


Hi Ashok,

I encounter runtime exception each time I call GetRowHeight() method, and I using GridTemplateColumn in my XAML. Do you have any idea why it crashed when call GetRowHeight()?

SfDataGrid version 15.3.0.33.

Error Message:

    Object reference not set to an instance of an object.

StackTrace:

at Syncfusion.SfDataGrid.XForms.Droid.MeasureSize.Convert (Xamarin.Forms.View view, Xamarin.Forms.VisualElement valid) [0x0002c] in <605b15f75385441483a1ceab754f747d>:0

at Syncfusion.SfDataGrid.XForms.Droid.MeasureSize.CalculateHeight (Syncfusion.SfDataGrid.XForms.SfDataGrid grid, Syncfusion.SfDataGrid.XForms.GridColumn column, Xamarin.Forms.View view) [0x0000a] in <605b15f75385441483a1ceab754f747d>:0

at Syncfusion.SfDataGrid.XForms.SfDataGridHelpers.GetTemplateHeight (Syncfusion.SfDataGrid.XForms.SfDataGrid grid, Syncfusion.SfDataGrid.XForms.GridColumn column, System.Object rowData, System.Int32 rowIndex) [0x00060] in <fe30172fa3ba4837bfbe14fa0c90fdf2>:0 

at Syncfusion.SfDataGrid.XForms.SfDataGridHelpers.GetRowHeight (Syncfusion.SfDataGrid.XForms.SfDataGrid datagrid, System.Object rowData, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.GridRowSizingOptions options) [0x0012e] in <fe30172fa3ba4837bfbe14fa0c90fdf2>:0 

at Syncfusion.SfDataGrid.XForms.SfDataGridHelpers.GetRowHeight (Syncfusion.SfDataGrid.XForms.SfDataGrid dataGrid, System.Int32 rowIndex, Syncfusion.SfDataGrid.XForms.GridRowSizingOptions options) [0x000c6] in <fe30172fa3ba4837bfbe14fa0c90fdf2>:0 


Regards,

CT



AN Ashok N Syncfusion Team November 6, 2017 10:04 AM UTC

Hi Chiew, 
 
Thanks for contacting Syncfuion support. 
 
We have checked your query and prepared the SfDataGrid sample with GridTemplateColumn and set the RowHeight by handling QueryRowHeight event in SfDataGrid v15.3.0.33 and Xamarin.Forms v2.3.3.180 but we are not able to reproduced the issue, SfDataGrid loaded properly and RowHeight has been calculated based on the GridCell value. For your reference we have attached sample and Screenshot in the below location, please check it. Could you please share your SfDataGrid and Xamarin.Forms version details, SfDataGrid.Columns creation code snippet, tested device details? Otherwise please do revert us by modifying our sample to replicate the issue or share your sample along with replication procedure, that would be more helpful for us to proceed further.   
     
 
 
Regards, 
Ashok 



CC CT CHANG November 7, 2017 03:06 AM UTC

Hi Ashok,


Thanks you for the sample code and I will have a look and compare it with my code.


Cheers,

CT



CC CT CHANG replied to Ashok N November 7, 2017 04:21 AM UTC

Hi Chiew, 
 
Thanks for contacting Syncfuion support. 
 
We have checked your query and prepared the SfDataGrid sample with GridTemplateColumn and set the RowHeight by handling QueryRowHeight event in SfDataGrid v15.3.0.33 and Xamarin.Forms v2.3.3.180 but we are not able to reproduced the issue, SfDataGrid loaded properly and RowHeight has been calculated based on the GridCell value. For your reference we have attached sample and Screenshot in the below location, please check it. Could you please share your SfDataGrid and Xamarin.Forms version details, SfDataGrid.Columns creation code snippet, tested device details? Otherwise please do revert us by modifying our sample to replicate the issue or share your sample along with replication procedure, that would be more helpful for us to proceed further.   
     
 
 
Regards, 
Ashok 


Hi Ashok,

I manage to locked down the root cause of the problem.

If I compile your sample code with Mono Framework 5.4.1.6, and upgrade the Xamarin.Forms to 2.4.0.38779. The program will crashed when call the DataGrid.GetRowHeight().

(see attachment: Mono Framework 4.8.1.png.zip)

But, when I compile the sample code with Mono Framework 4.8.1 (without changing anything, Xamarin.Forms 2.3.3.180), everything work well.

(see attachment: Mono Framework 5.4.1.6.png.zip)

Therefore, when will this be fix in Xamarin.Forms 2.4.0.38779 with Mono Framework 5.4.1.6 ?


Cheers,

CT



Attachment: Mono_Framework_5.4.1.6.png_fb34d37e.zip


CC CT CHANG November 7, 2017 04:23 AM UTC

Hi Ashok,

Here is another attached screen captured. Which I missed out in my previous post.

Cheers,

CT


Attachment: Mono_Framework_4.8.1.png_403deb1f.zip


CC CT CHANG November 7, 2017 04:38 AM UTC

Hi Ashok,

Here is another exception stack trace captured by RayGun.

Cheers,
CT

Attachment: ExceptionByRaygun_8d3794cb.zip


AN Ashok N Syncfusion Team November 7, 2017 12:58 PM UTC

Hi Chang, 
 
We are sorry for the inconvenience caused. 
 
We have checked your screenshot and you are using Xamarin.Forms v2.4.0.38779 but we have support Xamarin.Forms v2.3.3.180 to our Syncfusion controls in 2017 Vol 3 SP2 release. Xamarin.Forms v2.4 stable version has been released after we freeze the 2017 Vol 3 SP2 release so this Syncfusion version won’t support Xamarin.Forms latest version. We will provide the Xamarin.Forms v2.4.0.280 support to our Syncfusion controls in our upcoming 2017 Vol 4 main release which will be schedule for rolls out within this week.  
 
You can get the details about the Syncfusion Xamarin.Forms components compatible from the below link:  
  
  
 
Note: We are able to reproduce the reported NullReferenceException with Xamarin.Forms v2.4.0.38779 and SfDataGrid v15.3.0.33 because of Xamarin.Forms version mismatch. This will be work with 2017 Vol 4 main release.  
 
Regards, 
Ashok 



CC CT CHANG November 7, 2017 10:18 PM UTC

Hi Ashok,

That great, and I will wait for the coming up 2017 Vol4 release.

Cheers,
CT


AN Ashok N Syncfusion Team November 8, 2017 05:53 AM UTC

Hi Chang, 
 
Thanks for your update, we will update you once release gets rolled out.  
 
Regards, 
Ashok 



CC CT CHANG November 14, 2017 02:36 AM UTC

Hi Ashok,

I just updated to the latest Syncfusion.Xamarin.SfDataGrid v15.4.0.17, and the GetRowHeight() work like charm! Thx.


Cheers,
T


AN Ashok N Syncfusion Team November 14, 2017 03:58 AM UTC

Hi Chang,  
  
Thanks for your update, please let us know if you require further assistance on this.  
  
Regards,  
Ashok  



Loader.
Live Chat Icon For mobile
Up arrow icon