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

GridTemplateColumn not resizing with resize allowed

Hello Syncfusion,

I have a problem with resizing columns on a GridTemplateColumn column.
I manually generate my columns by reflection on my objects and instantiates a template according to the type.

So far everything is fine, on a simple object with basic properties the columns resize correctly.
Nevertheless, when I have a property that represents another class the columns do not resize anymore.

I set the columnsizer to Auto and the allowresizing property to true.

Can you help me to resolve this please ?


Best regards,

Alexandre Leclerc.


PS : Your forum thread edit control doesnt work properly. It removes all Layout.

Attachment: generatecolumn_237fb62e.zip

8 Replies

LA Leclerc Alexandre July 25, 2017 03:16 PM UTC

Hello again,

I realized that the complexe properties are not in cause. I forgot to mention I use a SfDataPager.

When I try to resize the column on the first page it won't work but when I move to a second page it work. And all along after that.

May be it will help you to find out why it has this behavior.

Thanks.




MK Muthukumar Kalyanasundaram Syncfusion Team July 26, 2017 03:06 PM UTC

Hi Leclerc, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your query. We are unable to reproduce the reported issue “GridTemplateColumn not resizing with resize allowed” in our end. For you reference, we have attached video and sample in the below location. In that, we have loaded dataGrid with TemplateColumn and datapager. The column resizing are working fine in first page and also when we move to other page. Could you please refer to it.   
 
 
 
If you are still facing the issue, could you please revert by modifying sample based on your application and also could you please conform your essential studio version ?. This would be helpful for us to provide an appropriate solution.  
 
Regards, 
Muthukumar K 



LA Leclerc Alexandre July 27, 2017 11:15 AM UTC

Hello,

I'm still facing the issue, I'm using nuget packages for my solution following this list :


PackageVersion
Syncfusion.Data.WPF
15.1460.0.41
Syncfusion.SfBusyIndicator.WPF
15.1460.0.41
Syncfusion.SfGrid.WPF
15.1460.0.41
Syncfusion.SfInput.Wpf
15.2460.0.40
Syncfusion.SfShared.Wpf
15.2460.0.40
Syncfusion.Shared.Wpf
15.1460.0.41

My Essential Studio version is : 13.4.0.53

On your video you move datapager first, but like I said : the behavior occures before moving pager. After selected an other page (just after loading) I can resize columns but if I do not change pages I can not resize columns. Looks like the ActualWidth property does not update.

Regarding the code, I'm not using AutoGeneratedColumn.

I'm using a SfDataGridHelper class (on my own), with LoadGridAsync method wich load columns manualy adding GridColumn objects whose follows (for complex objects) this construct :

  var col = new GridTemplateColumn
                          {
                              MappingName   = colName,
                              HeaderText    = headerText,
                              CellTemplate  = cTmp,
                              EditTemplate  = eTmp,
                              ColumnSizer   = GridLengthUnitType.Auto,
                              AllowResizing = true
                          };

What is in CellTemplate and EditTemplate are DataTemplate, for example :

 var txtBlck = new FrameworkElementFactory(typeof(TextBlock));
 txtBlck.SetBinding(TextBlock.TextProperty, new Binding(colName));
 txtBlck.SetValue(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center);

var elmtFct   = new FrameworkElementFactory(typeof(ComboBox));

(lst is an List<object>)

elmtFct.SetValue(ItemsControl.ItemsSourceProperty, lst);
elmtFct.SetBinding(Selector.SelectedValueProperty, new Binding(propertyName));

var cellTemplate = new DataTemplate { VisualTree = txtBlck };

var editTemplate = new DataTemplate { VisualTree = elmtFct };

var col = new GridTemplateColumn
               {
                   MappingName   = colName,
                   HeaderText    = headerText,
                   CellTemplate  = cellTemplate,
                   EditTemplate  = editTemplate,
                   ColumnSizer   = GridLengthUnitType.Auto,
                   AllowResizing = true
               };

columns.Add(col);

(columns is bind to my viewmodel and type with Columns in Syncfusion.SfGrid.WPF assembly).

Binding are like this in xaml :

  <syncfusion:SfDataGrid Grid.Row="0" x:Name="MDataGrid" ItemsSource="{Binding ElementName=DataPager, Path=PagedSource}"
                                       Columns="{Binding GridViewModel.Columns, Mode=TwoWay}">                          
                </syncfusion:SfDataGrid>

 <syncfusion:SfDataPager Grid.Row="1" x:Name="DataPager"
                                        DataContext="{Binding GridViewModel}"
                                        PageSize="35"
                                        IsEnabled="{Binding EnablePager}"
                                        Source="{Binding Items}" >
                </syncfusion:SfDataPager>

Items is an ObservableCollection<object>.

May be these details will help you to understand the issue.

Do not hesitate to ask me more details. I don't share my sources because they are private and is a little bit more heavy. I tried to specify the most important things.

Hope that is clearer with these details. Meanwhile,

Have a nice day,

Regards, Alexandre Leclerc.



LA Leclerc Alexandre July 28, 2017 02:56 PM UTC

Hello Again Syncfusion,

I have noticed columns can be resized when I resized the window. In other words, when the grid get redraw, the columns width update properly.

So, I tried to call Refresh, InvalidateVisual, UpdateLayout and rerender the view with Dispatcher, without any good results.

May be that can help you to find something. 



LA Leclerc Alexandre July 31, 2017 07:31 AM UTC

Hello Syncfusion, I found out why this behavior occurs.

It seem's columns needs to be add before items for the refresh UI. I think the visual needs content of columns to calculate width.

So, when I'm adding columns first then items secondly I can resize columns without any issues.

Thanks for your support. Have a nice day.




MK Muthukumar Kalyanasundaram Syncfusion Team August 1, 2017 04:08 AM UTC

Hi Leclerc,   
 
Thanks for the update.   
 
We are glad that you have fixed your issue. Please let us know if you need any other assistance.   
 
Regards,  
Muthukumar K 



CC CT CHANG replied to Leclerc Alexandre June 6, 2019 05:30 AM UTC

Hello Syncfusion, I found out why this behavior occurs.

It seem's columns needs to be add before items for the refresh UI. I think the visual needs content of columns to calculate width.

So, when I'm adding columns first then items secondly I can resize columns without any issues.

Thanks for your support. Have a nice day.



Hi Leclerc Alexandre,

You info safe my time. Thanks!

Regards,
CT


JP Jagadeesan Pichaimuthu Syncfusion Team June 7, 2019 09:44 AM UTC

Hi Leclerc, 
  
Thanks for using Syncfusion products. 
 
We are glad to know that the thread is useful to you. Contact us if need any further assistance. 
  
Regards, 
Jagadeesan 


Loader.
Live Chat Icon For mobile
Up arrow icon