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
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.
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
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.
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
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,
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.
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
Why not use RadTreeListView instead?
Sincerely yours,Vlad
the Telerik team
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.
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
{
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
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.
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.