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
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.
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(); |
} |
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.
BestFitColumns
Bestfitcolumns on child data in the grid ? please give example thanksThank 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
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 >>
Using the suggested logic still cannot bestfit child template in hierarchical grid.
Is this fixed in new releases?
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
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
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
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!