Sharing Parent column width in child grid

13 posts, 0 answers
  1. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 12 Jan 2010 Link to this post

    Hi telerik,

    I am using RadGridView for multilevel hirarchy. I shown multiple levels in RadGrid View..
     But while showing child Grid ,  column width is very small as respective parent Grid column. 
    I want to show column in child Grid width is equal to parent Grid column and when I am going resizing parent column then child grid  respective column should be resize automatically... 
     This description is also mention in attached image to this thread.
    U can understand my problem  very easily when u see the attached file...
    Pls Help me for this issue .. 


    Thanks
    Ganesh
       
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 13 Jan 2010 Link to this post

    Hi Ganesh Jagdale,

    Unfortunately the current version of RadGridView does not support such functionality.
    There is a way to accomplish such behavior it involves a ton of hacks which I would definitely not recommend as it would be complicated and hard to maintain.  

    Regards,
    Pavel Pavlov
    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. DevCraft banner
  4. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 13 Jan 2010 Link to this post

    HI  Pavel Pavlov,
      Thank God...
       My Problem is solved..
    U said that It is not possible .. possible but using tons of hacking..
     
    I write following code in

    "DataLoading event of grid"

     

     

    if (i == 1)

     

    {

    grid.Columns[i].Width =

    new GridViewLength(grid.ParentRow.Cells[i - 1].RenderSize.Width - count);

     

    }

     

    else

     

     

     

     

     

    {

    grid.Columns[i].Width =

    new GridViewLength(grid.ParentRow.Cells[i - 1].RenderSize.Width);

     

    }

     
    using this all child and parent coloumn width come in same width...

    but Now My Problem is
    --> When I am going to resize parent Grid column that changes is not reflected in child Grid Column..

    For achiving this , is there any event to be handled so that i should get changeable   size (means when resizing only two column width changes )..

    Pls suggest me the solution..
    It will greatly help me..

    Thanks,
    Ganesh



  5. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 14 Jan 2010 Link to this post

    Hi Ganesh Jagdale,

    Please see the attached project. It demonstrates  how you can track gridview column width changes using the advantage of dependency properties.

    I hope this helps.

    Greetings,
    Tsvyatko
    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. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 19 Jan 2010 Link to this post

    Hi  Tsvyatko,

    You are giving me best solution to track the changingColumnWidth using DependancyProperty..

    But for changing all child grids Column I need to access that all child gids and set to columnWidth  to newer value..
    But my Parent grid may contain many relation which I bind at runtime.. For this I need to iterate through all this Relation and set their  ColumnWidth property of respective Child Grid .. It is very time consuming ..

    so  Is there way to handling this which can be less overhead?
    is there any way to binding so that it will reflected in all child Grid(ChildDefinations) automaticaly?

    Pls Help me ... 

    Thanks
    Ganesh


  7. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 22 Jan 2010 Link to this post

    Hi Ganesh Jagdale,

    Since Column Width is not dependency property one can not get full advantage of binding mechanisms. We are planning to improve this in some of our future release. The sample project from the previous post is the workaround that is the closest to binding natural mechanisms in Silverlight.

    Best wishes,
    Tsvyatko
    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.
  8. Barry
    Barry avatar
    31 posts
    Member since:
    Feb 2010

    Posted 21 Sep 2010 Link to this post

    Hello Ganesh Jagdale,

    Im trying to do the same thing. Can you please paste your complete code for

    if (i == 1)

     

    {

    grid.Columns[i].Width =

     

     

    new GridViewLength(grid.ParentRow.Cells[i - 1].RenderSize.Width - count);

     

    }

     

    else

    {

    grid.Columns[i].Width =

     

     

    new GridViewLength(grid.ParentRow.Cells[i - 1].RenderSize.Width);

     

    }

     

     

     

     



    Thanks
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 21 Sep 2010 Link to this post

    Hi Barry,

     Why not use RadTreeListView instead?

    Sincerely yours,
    Vlad
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Barry
    Barry avatar
    31 posts
    Member since:
    Feb 2010

    Posted 21 Sep 2010 Link to this post

    Hello Vlad,

    Thanks for the quick response. Im not yet familiar with the RadTreeListView. Looking into that control im wondering if it could satisfy my desired output. Please see attachment.  Im looking into RadGrivView to achieve this result. Please advice.
  11. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 21 Sep 2010 Link to this post

    Hi Berry,
        Following Solution I had,
      private ColumnWdthBinder binder;
    This ColumnWdthBinder                    this class you will found in previous attached files (given by Vlad).

    Following code in DataLoading event of RadGridView        

     private void PersonGrid_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e)
            {
    var grid = (GridViewDataControl)sender;
                if (grid.Columns.Count != 0)
                {
                    return;
                }

     int count = 24;
                grid.ShowColumnHeaders = grid.ParentRow == null;
                grid.ShowGroupPanel = grid.ParentRow == null;
               
                if (grid.ParentRow != null)
                {
                  
                    VPersonManagerViewSurrogated parentPerson = grid.ParentRow.DataContext as VPersonManagerViewSurrogated;

                    List<VPersonManagerViewSurrogated> filteredPersonManagerList =
                        personManagerList.Where(p => p.ManagerId.Equals(parentPerson.PersonId)).ToList();
                    if (filteredPersonManagerList != null)
                    {
                        e.ItemsSource = filteredPersonManagerList;
                        var definition = grid.TableDefinition;
                        var d = new GridViewTableDefinition();
                        d.Relation = new PropertyRelation("Subordinates");
                        definition.ChildTableDefinitions.Add(d);
                        definition = d;
                    }
                }

    grid.AutoGenerateColumns = false;

                GridViewDataColumn dataColumn = new GridViewDataColumn() { DataMemberBinding = new Binding("PersonId") };
                dataColumn.IsVisible = false;
                grid.Columns.Add(dataColumn);
               
                dataColumn = new GridViewDataColumn() { DataMemberBinding = new Binding("FirstName") };
                if (grid.ParentRow != null)
                {
                    dataColumn.Width = new GridViewLength(grid.ParentRow.Cells[0].RenderSize.Width - count);
                }
                dataColumn.Header = "First Name";
                grid.Columns.Add(dataColumn);
    //like that add other column

    if (grid.ParentOfType<RadGridView>() != null)
                {
                    for (int i = 0; i < grid.Columns.Count; i++)
                    {
                        this.binder.RegisterColumn(grid.Columns[i], i);
                    }
                }
    }



    Berry,Please let me know  if it work for you..
    Thanks,
    Ganesh

  12. Barry
    Barry avatar
    31 posts
    Member since:
    Feb 2010

    Posted 25 Sep 2010 Link to this post

    Thansk Ganesh,

    Unfortunately, I was not able to test the code the you have provided, we saw that using child  grids within a grid would just complicate on how we would address a certain requirement. Instead we just switched to using a single RadGridView.

  13. Jayaraman
    Jayaraman avatar
    1 posts
    Member since:
    Mar 2015

    Posted 04 Apr in reply to Ganesh Jagdale Link to this post

    Ganesh Could you please provide a sample working code. I have a similar issue
  14. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 04 Apr in reply to Jayaraman Link to this post

    Hello Jayaraman,

    Right now I do not have that sample working code in hand. As that one is 5 yr back..:). But I had already shared main core code snippet with which I solved my issue.

Back to Top
DevCraft banner