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

How to define Height of GroupColumnDescription ?

I have a custom cell as below, so RowHeight = 200, if i do groupping, GroupColumnDescription  Height becomes also 200. Is it possible to define or reduce the height of GroupColumnDescription ? 


    <sfgrid:SfDataGrid  ScrollingMode="PixelLine"             
                         AutoGenerateColumns="False"
                         AllowSorting="True"   
                            IsEnabled="True"  
                         ColumnSizer="Star"
                         AllowSwiping="True"
                         AllowDraggingRow="True"
                        AllowDraggingColumn="False"
                         MaxSwipeOffset="150"
                          GridTapped="dataGrid_GridTapped"
                         SelectionMode="Single"
                           AutoExpandGroups="True"
                        AllowGroupExpandCollapse="True"
                         RowHeight="200" 

<sfgrid:SfDataGrid.GroupColumnDescriptions>
          <sfgrid:GroupColumnDescription ColumnName="level" Height="20"/>
        </sfgrid:SfDataGrid.GroupColumnDescriptions>


 <sfgrid:GridTemplateColumn.CellTemplate>

              <DataTemplate>
                <Grid BackgroundColor="White" Padding="10" RowSpacing="20">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>

                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="10"></RowDefinition>
                  </Grid.RowDefinitions>

                  <StackLayout Orientation="Vertical" Grid.Row="0" Grid.Column="0" >

                    <Label TextColor="Black"  Text="{Binding level}"/>                
                    <Label  TextColor="Black"   Text="{Binding name}" StyleClass="Header"  />                    

                  </StackLayout>
                  <BoxView Grid.Row="1"  Grid.Column="0" Grid.ColumnSpan="2"  HorizontalOptions="FillAndExpand" BackgroundColor="Black"></BoxView>                  
                </Grid>
              </DataTemplate>

            </sfgrid:GridTemplateColumn.CellTemplate>

7 Replies

DS Divakar Subramaniam Syncfusion Team December 12, 2016 07:30 AM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. You can achieve your requirement by using SfDataGrid.QueryRowHeight event. Please refer the below code snippet for more details. 
private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    var rowData = dataGrid.GetRecordAtRowIndex(e.RowIndex); 
    if(rowData == null && e.RowIndex != 0) 
    { 
        e.Height = 100; 
        e.Handled = true; 
    } 
} 
  
In the above snippet, we get the row data and checked whether the row is caption summary row or record row. If the row is caption summary row, then we have applied the row height. 
Also, we have attached the sample for your reference and you can download the same from the below link. 
 
Regards, 
Divakar. 



EM Emil December 12, 2016 11:15 AM UTC

Hi Divakar,

thanks fro your help but it doesnt work correctly. If I have 2 goups and each has 4 items. When I expand 2nd. group and then try to collapse again, It throws an exception as  3 out of range 0 to 2 Parameter name: from exception as details below. 

System.Argu

3 out of range 0 to 2 Parameter name: frommentOutOfRangeException3 out of range 0 to 2 Parameter name: fr

  at Syncfusion.GridCommon.ScrollAxis.DistanceRangeCounterCollection.CheckRange (System.String paramName, System.Int32 from, System.Int32 to, System.Int32 actualValue) [0x00046] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.DistanceRangeCounterCollection.SetRange (System.Int32 from, System.Int32 to, System.Double distance) [0x0000d] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.LineSizeCollection.InitializeDistances () [0x00101] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.LineSizeCollection.ResumeUpdates () [0x0001e] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.SfDataGrid.XForms.GridModel.CollapseGroup (Syncfusion.Data.Group group) [0x000ed] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Syncfusion.SfDataGrid.XForms.SpannedDataRow.IsExpandedChanged (System.Boolean isExpanded) [0x00032] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Syncfusion.SfDataGrid.XForms.CaptionSummaryRowControl.RaisePointerTouchUp () [0x00025] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Xamarin.Forms.Command+<>c__DisplayClass3_0.<.ctor>b__0 (System.Object o) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:73 
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:107 
  at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View sender) [0x00018] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\TapGestureRecognizer.cs:42 
  at Xamarin.Forms.Platform.Android.TapGestureHandler.OnTap (System.Int32 count) [0x00028] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\TapGestureHandler.cs:36 
  at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnSingleTapUp (Android.Views.MotionEvent e) [0x0001c] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\InnerGestureListener.cs:125 
  at Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnSingleTapUp_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.GestureDetector.cs:681 
  at (wrapper dynamic-method) System.Object:6af99487-6f40-40c1-a637-a184e25c36d4 (intptr,intptr,intptr)


AN Ashok N Syncfusion Team December 13, 2016 12:49 PM UTC

Hi Emil, 

Please ignore our previous update. 

You can achieve your requirement by hadling SfDataGrid.QueryRowHeight event. Please refer the below code example 
dataGrid.QueryRowHeight += DataGrid_QueryRowHeight; 

private void DataGrid_QueryRowHeight(object sender, QueryRowHeightEventArgs e) 
{ 
    if (SfDataGridHelpers.IsCaptionSummaryRow(this.dataGrid, e.RowIndex)) 
    { 
        e.Height = 100; 
        e.Handled = true; 
    } 
} 
  
Regards, 
Ashok 



EM Emil December 13, 2016 04:10 PM UTC

Hi Ashok,

thanks fro your help but it still didnt make any change for me. I am still getting same exception as below 
This is only happening if I click expand and try to collapse last group again. 



Xamarin caused by: android.runtime.JavaProxyThrowable: System.ArgumentOutOfRangeException: 3 out of range 0 to 2
Parameter name: from
  at Syncfusion.GridCommon.ScrollAxis.DistanceRangeCounterCollection.CheckRange (System.String paramName, System.Int32 from, System.Int32 to, System.Int32 actualValue) [0x00046] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.DistanceRangeCounterCollection.SetRange (System.Int32 from, System.Int32 to, System.Double distance) [0x0000d] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.LineSizeCollection.InitializeDistances () [0x00101] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.GridCommon.ScrollAxis.LineSizeCollection.ResumeUpdates () [0x0001e] in <23738da4e53c4b0d8a14abe2c3571131>:0 
  at Syncfusion.SfDataGrid.XForms.GridModel.CollapseGroup (Syncfusion.Data.Group group) [0x000ed] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Syncfusion.SfDataGrid.XForms.SpannedDataRow.IsExpandedChanged (System.Boolean isExpanded) [0x00032] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Syncfusion.SfDataGrid.XForms.CaptionSummaryRowControl.RaisePointerTouchUp () [0x00025] in <0e18c3999f324e928a6ea83b75eca1f0>:0 
  at Xamarin.Forms.Command+<>c__DisplayClass3_0.<.ctor>b__0 (System.Object o) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:73 
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:107 
  at Xamarin.Forms.TapGestureRecognizer.SendTapped (Xamarin.Forms.View sender) [0x00018] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Core\TapGestureRecognizer.cs:42 
  at Xamarin.Forms.Platform.Android.TapGestureHandler.OnTap (System.Int32 count) [0x00028] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\TapGestureHandler.cs:36 
  at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnSingleTapUp (Android.Views.MotionEvent e) [0x0001c] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\InnerGestureListener.cs:125 
  at Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnSingleTapUp_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00011] in /Users/builder/data/lanes/3511/ce955cc0/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.GestureDetector.cs:681 
  at (wrapper dynamic-method) System.Object:652a7c8c-f50b-43be-9679-4dcecda552f5 (intptr,intptr,intptr)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.InnerGestureListener.n_onSingleTapUp(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.InnerGestureListener.onSingleTapUp(InnerGestureListener.java:79)
	at android.view.GestureDetector.onTouchEvent(GestureDetector.java:635)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.n_onTouch(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.VisualElementRenderer_1.onTouch(VisualElementRenderer_1.java:57)
	at android.view.View.dispatchTouchEvent(View.java:9290)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2547)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2240)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.n_dispatchTouchEvent(Native Method)
	at md5b60ffeb829f638581ab2bb9b1a7f4f3f.PlatformRenderer.dispatchTouchEvent(PlatformRenderer.java:55)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2553)
	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2254)
	at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2403)
	at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1737)
	at android.app.Activity.dispatchTouchEvent(Activity.java:2765)
	at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
	at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
	at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2364)
	at android.view.View.dispatchPointerEvent(View.java:9514)
	at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4230)
	at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4096)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
	at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3787)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
	at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3844)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
	at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3695)
	at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3661)
	at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3669)
	at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3642)
	at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5922)
	at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5896)
	at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5857)
	at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6025)
	at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:323)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5417)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)


EM Emil December 13, 2016 04:26 PM UTC

I made several further tests and I recognized that it only occurs for last group. Basically I cannot collapse the last group when I use QueryRowHeight event. It throws this exception everytime. If i dont use QueryRowHeight, using default, everything works fine.


EM Emil December 13, 2016 04:36 PM UTC

Further more information, my datagrid is defined as below, as you can see RowHeight is defined 200, If I remove this, it doesnt crash because It will automatically resize as same height as group caption. So from that I understand it that it occurs only when row height is different than caption height

  <sfgrid:SfDataGrid  ScrollingMode="PixelLine"  x:Name="datagrid"
                         AutoGenerateColumns="False"
                         AllowSorting="True"
                            IsEnabled="True"
                         ColumnSizer="Star"
                         AllowSwiping="True"
                         AllowDraggingRow="True"
                        AllowDraggingColumn="False"
                         MaxSwipeOffset="150"
                          GridTapped="dataGrid_GridTapped"
                         SelectionMode="Single"
                           AutoExpandGroups="True"
                        AllowGroupExpandCollapse="True"
                         RowHeight="200" ItemsSource="{Binding Items}"
              SelectedItem="{Binding SelectedItem}"  VerticalOptions="FillAndExpand">


AN Ashok N Syncfusion Team December 14, 2016 07:45 AM UTC

Hi Emil,   
   
We are sorry about the inconvenience caused. 
   
We are able to reproduced the ArgumentOutOfRangeException while Collapse the last Group in Xamarin.Forms. A support incident has been created under your account. Please log on to our support website to check for further updates:    
     
    
Regards,    
Ashok    


Loader.
Live Chat Icon For mobile
Up arrow icon