ChildGridViewTemplates and BestFitColumns

12 posts, 0 answers
  1. Jorge Delgado-Lopez
    Jorge Delgado-Lopez avatar
    82 posts
    Member since:
    Aug 2007

    Posted 30 Sep 2009 Link to this post

    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

  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 05 Oct 2009 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. jpl
    jpl avatar
    8 posts
    Member since:
    Aug 2008

    Posted 14 Oct 2009 Link to this post

    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();  
     
    }  
     
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 20 Oct 2009 Link to this post

    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.
  6. Oleg
    Oleg avatar
    2 posts
    Member since:
    Dec 2013

    Posted 19 Dec 2013 Link to this post

    Hi has there been any update to the

    BestFitColumns

    Bestfitcolumns on child data in the grid ? please give example thanks
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 20 Dec 2013 Link to this post

    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 >>
  8. Freddie
    Freddie avatar
    2 posts
    Member since:
    Aug 2014

    Posted 02 Sep 2014 in reply to Stefan Link to this post

    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?
  9. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 03 Sep 2014 Link to this post

    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.
     
  10. Abba
    Abba avatar
    22 posts
    Member since:
    Jan 2013

    Posted 10 Aug Link to this post

    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

     

  11. Aaron Abdis
    Aaron Abdis avatar
    24 posts
    Member since:
    Mar 2005

    Posted 10 Oct in reply to Stefan Link to this post

    This seems to be working fine for me with the first ChildView, but not any additional ones.
  12. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 11 Oct Link to this post

    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.
  13. Aaron Abdis
    Aaron Abdis avatar
    24 posts
    Member since:
    Mar 2005

    Posted 11 Oct in reply to Hristo Merdjanov Link to this post

    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!

Back to Top
UI for WinForms is Visual Studio 2017 Ready