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

Sharing Parent column width in child grid

12 Answers 437 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ganesh Jagdale
Top achievements
Rank 1
Ganesh Jagdale asked on 12 Jan 2010, 09:13 AM
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
   

12 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 13 Jan 2010, 09:51 AM
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.
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 13 Jan 2010, 03:17 PM
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



0
Tsvyatko
Telerik team
answered on 14 Jan 2010, 09:25 AM
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.
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 19 Jan 2010, 12:42 PM
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


0
Tsvyatko
Telerik team
answered on 22 Jan 2010, 12:20 PM
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.
0
Barry
Top achievements
Rank 1
answered on 21 Sep 2010, 09:34 AM

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
0
Vlad
Telerik team
answered on 21 Sep 2010, 09:47 AM
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
0
Barry
Top achievements
Rank 1
answered on 21 Sep 2010, 11:20 AM
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.
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 21 Sep 2010, 04:16 PM
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

0
Barry
Top achievements
Rank 1
answered on 25 Sep 2010, 05:41 AM
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.

0
Jayaraman
Top achievements
Rank 1
answered on 04 Apr 2016, 12:58 PM
Ganesh Could you please provide a sample working code. I have a similar issue
0
Ganesh Jagdale
Top achievements
Rank 1
answered on 04 Apr 2016, 01:15 PM

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.

Tags
GridView
Asked by
Ganesh Jagdale
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Ganesh Jagdale
Top achievements
Rank 1
Tsvyatko
Telerik team
Barry
Top achievements
Rank 1
Vlad
Telerik team
Jayaraman
Top achievements
Rank 1
Share this question
or