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.
Unfortunately, activation email could not send to your email. Please try again.

GridTemplateColumn not resizing with resize allowed

Thread ID:

Created:

Updated:

Platform:

Replies:

131730 Jul 25,2017 09:05 AM Aug 1,2017 12:08 AM WPF 6
loading
Tags: SfDataGrid
Leclerc Alexandre
Asked On July 25, 2017 09:05 AM

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

Leclerc Alexandre
Replied On July 25, 2017 11:16 AM

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.



Muthukumar Kalyanasundaram [Syncfusion]
Replied On July 26, 2017 11:06 AM

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 


Leclerc Alexandre
Replied On July 27, 2017 07:15 AM

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.


Leclerc Alexandre
Replied On July 28, 2017 10:56 AM

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. 


Leclerc Alexandre
Replied On July 31, 2017 03:31 AM

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.



Muthukumar Kalyanasundaram [Syncfusion]
Replied On August 1, 2017 12:08 AM

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 


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.

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.

;