This is a migrated thread and some comments may be shown as answers.

ChildGridViewTemplates and BestFitColumns

11 Answers 245 Views
GridView
This is a migrated thread and some comments may be shown as answers.
superold
Top achievements
Rank 1
superold asked on 30 Sep 2009, 04:23 PM

Hi,

I need to run BestFitColumns on a hierarchical grid.
 
The master view template works fine, but I can't seem to get it to work with the child columns.

I am doing the following:

someGrid.MasterGridViewTemplate.ChildGridViewTemplates[0].BestFitColumns();  

Thanks
- jorge

11 Answers, 1 is accepted

Sort by
0
Martin Vasilev
Telerik team
answered on 05 Oct 2009, 02:48 PM
Hi Jorge Delgado-Lopez,

Thank you for writing. Although we have BestFitColumns method in every grid template, currently we do not support best fit in child views. We will include this feature in some of the next releases. I have updated your Telerik points for bringing our attention to this matter. Do not hesitate to contact me again if you have other questions.

Greetings,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
jpl
Top achievements
Rank 1
answered on 14 Oct 2009, 05:21 PM
Hi,

I need also this functionnality. I noticed that when one doubleclik betwen two child view columns the left one does fit. However, after the ChildViewExpanded event is fired, calling BestFit() does not work. How to programmatically call the same function that produces the column fit when doubleclicked on the border ?

this does not work :

 

 
 
protected override void OnChildViewExpanded(object sender, ChildViewExpandedEventArgs e){  
 
base.OnChildViewExpanded(sender, e);  
 
foreach(GridViewDataColumn column in e.ChildViewInfo.ViewTemplate.Columns)  
 
column.BestFit();  
 
}  
 
0
Martin Vasilev
Telerik team
answered on 20 Oct 2009, 09:13 AM
Hi jpl,

Thank you for contacting us. Unfortunately, there is no way to use double click AutoSize functionality using code. Please, excuse us for the inconvenience.

Sincerely yours,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Oleg
Top achievements
Rank 1
answered on 19 Dec 2013, 04:14 PM
Hi has there been any update to the

BestFitColumns

Bestfitcolumns on child data in the grid ? please give example thanks
0
Stefan
Telerik team
answered on 20 Dec 2013, 11:05 AM
Hello Oleg,

Thank you for writing.

You can best fit the columns in child templates by using the ChildViewExpanded event handler:
void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
{
    e.ChildViewInfo.ViewTemplate.BestFitColumns();
}

I hope this helps.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Freddie
Top achievements
Rank 1
answered on 02 Sep 2014, 08:58 PM
I am using UI for WinForms version 2014.1 226

Using the suggested logic still cannot bestfit child template in hierarchical grid. 

Is this fixed in new releases?
0
Stefan
Telerik team
answered on 03 Sep 2014, 10:42 AM
Hello Freddie,

The provided approach in my previous post works correctly on my end with both the latest version and the version you mentioned. If you still experience issues, I would suggest opening a support ticket where you can attach the problematic project and we will gladly look into it.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Abba
Top achievements
Rank 1
answered on 11 Aug 2016, 12:16 AM

This is also not working for me.  has anything changed or is it still supposed to work this way?

Also, I am trying to add filtering and excel filtering.  I added the following:

        e.ChildViewInfo.ViewTemplate.ShowFilterCellOperatorText = False
        e.ChildViewInfo.ViewTemplate.ShowHeaderCellButtons = True

 

is this correct in the child expanded event to work?

 

thanks

 

0
Aaron Abdis
Top achievements
Rank 1
answered on 10 Oct 2016, 08:03 PM
This seems to be working fine for me with the first ChildView, but not any additional ones.
0
Hristo
Telerik team
answered on 11 Oct 2016, 10:49 AM
Hi Aaron,

Thank you for writing back.

The ChildViewInfo received as an event argument is the active view of the template and it successfully best fits its columns. I am assuming that you are having multiple views on one level.

In a scenario in which there are more than one views you can best fit them this way: 
private void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
{
    GridViewHierarchyRowInfo parent = e.ParentRow as GridViewHierarchyRowInfo;
    if (parent != null)
    {
        foreach (GridViewInfo view in parent.Views)
        {
            view.ViewTemplate.BestFitColumns();
        }
    }
}

Abba, perhaps you are having the same scenario. Can you try accessing the views as per my suggestion above? Please also do not forget to set the EnableFiltering property of your templates to true.

Alternatively, you can always access the view templates while you are creating them or at a later stage: Accessing Child Templates. I am also attaching a short video showing the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms. For more information check out this blog post and share your thoughts.
0
Aaron Abdis
Top achievements
Rank 1
answered on 11 Oct 2016, 04:18 PM

Hi Hristo,

Thanks so much for that snippet! I had a feeling it was something along those lines, but poking around through Object Explorer and Intellisense, I had been unable to find the proper properties to get to that child view collection.

This worked perfectly!

Cheers!

Tags
GridView
Asked by
superold
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
jpl
Top achievements
Rank 1
Oleg
Top achievements
Rank 1
Stefan
Telerik team
Freddie
Top achievements
Rank 1
Abba
Top achievements
Rank 1
Aaron Abdis
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or