Hi there
Does anyone know how to align columns in a hierachical grid.
We need a treeview like control with several columns - and the telerik grid seems good - but all the columns are out of alignment - resulting in a messy end user experience.
Or, if this can't be done with the grid - should we be using a treeview?
Thanks very much
Tim Huffam
Does anyone know how to align columns in a hierachical grid.
We need a treeview like control with several columns - and the telerik grid seems good - but all the columns are out of alignment - resulting in a messy end user experience.
Or, if this can't be done with the grid - should we be using a treeview?
Thanks very much
Tim Huffam
7 Answers, 1 is accepted
0
Hi Tim,
Please check this article:
http://www.telerik.com/help/aspnet-ajax/grdaligncolumnsinhierarchy.html
The other option is the treeview with templates.
Sincerely yours,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please check this article:
http://www.telerik.com/help/aspnet-ajax/grdaligncolumnsinhierarchy.html
The other option is the treeview with templates.
Sincerely yours,
Vlad
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tim
Top achievements
Rank 1
answered on 31 Jul 2008, 11:20 PM
Thanks for the answer.
Any idea how we can do this programmatically?
We've been unable to create a hierachical grid programmatically - it only displays as a standard grid with no nesting. Could you please provide code of a simple example of this.
Thanks again
Tim
Any idea how we can do this programmatically?
We've been unable to create a hierachical grid programmatically - it only displays as a standard grid with no nesting. Could you please provide code of a simple example of this.
Thanks again
Tim
0
Tim
Top achievements
Rank 1
answered on 01 Aug 2008, 04:45 AM
Hi there
I've found some telerik articles on doing this programmatically - however in our case we are using one data source that selfjoins eg with the following database columns: Id, ParentId, Description
It has 4 levels - so I've copied your sample code (customer, order, orderlines) and adapted to use this one table (datasource - which is a generic List<>) - however it is only allowing me to show 2 levels - when I try to expand the second level I get the following error: "Parent table relations set, but no correspoding data-key name found "
Here's some of my code that sets up the relationship:
And is there anyway to get the top level to only show the top level parent items (where parentId = -1) - I've tried the following but it does not work:
I've found some telerik articles on doing this programmatically - however in our case we are using one data source that selfjoins eg with the following database columns: Id, ParentId, Description
It has 4 levels - so I've copied your sample code (customer, order, orderlines) and adapted to use this one table (datasource - which is a generic List<>) - however it is only allowing me to show 2 levels - when I try to expand the second level I get the following error: "Parent table relations set, but no correspoding data-key name found "
Here's some of my code that sets up the relationship:
tableView.DataKeyNames =
new string[] { "Id", "ParentId"};
GridRelationFields relationFields = new GridRelationFields();
relationFields.MasterKeyField =
"Id";
relationFields.DetailKeyField =
"ParentId";
tableView.ParentTableRelation.Add(relationFields);
And is there anyway to get the top level to only show the top level parent items (where parentId = -1) - I've tried the following but it does not work:
grid
.MasterTableView.FilterExpression = "ParentId = -1";
Thanks very much
Tim
0
Hello Tim,
I suggest that you have a look at this online demo showing the self-referencing hierarchy model of Telerik RadGrid. The self-referencing hierarchy of RadGrid allows you to build multiple levels of hierarchy from a single table in the data source by specifying relations inside the same table.
The programmatic creation of such grid would same as for one level grid with addition that you need to set through code behind the SelfReferencingSettings property of the MasterTableView.
You can find more information about RadGrid programmatic creation here.
Give it a try and let us know if you need further directions.
Kind regards,
Iana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I suggest that you have a look at this online demo showing the self-referencing hierarchy model of Telerik RadGrid. The self-referencing hierarchy of RadGrid allows you to build multiple levels of hierarchy from a single table in the data source by specifying relations inside the same table.
The programmatic creation of such grid would same as for one level grid with addition that you need to set through code behind the SelfReferencingSettings property of the MasterTableView.
You can find more information about RadGrid programmatic creation here.
Give it a try and let us know if you need further directions.
Kind regards,
Iana
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tim
Top achievements
Rank 1
answered on 03 Aug 2008, 11:52 PM
Hi there
Thanks very much for your response.
I've tried several versions of what these articles suggest but they do not work - all with varying functionality.
It appears that the self-joining hierachical functionality only works best when defining the grid declaratively. Also, it only works correctly if it autogenerates the columns - if I programmatically create them it does not implement the expand/collapse functionality. The best I could achieve is getting the first level (MasterTableView) to provide expand/collapse functionality.
Ideally we want to programmatically implement this (self-joining hierarchical grid) - so we have full control over all columns and also so we can unit test the code. And also we'd like to be able to create our own class which inherits from RadGrid - so we can encapsulate all this behaviour.
However in the interest of delivering a working solution we'll use any method - and currently the declarative seems the only way that this works. So the outstanding problems are that it is creating the columns in the incorrect sequence (setting column.OrderIndex within CategoryOnColumnCreated does not work) and the columns are not in alignment.
Any suggestions (and ideally an example of how to do this programmatically).
Thanks again
Tim
Thanks very much for your response.
I've tried several versions of what these articles suggest but they do not work - all with varying functionality.
It appears that the self-joining hierachical functionality only works best when defining the grid declaratively. Also, it only works correctly if it autogenerates the columns - if I programmatically create them it does not implement the expand/collapse functionality. The best I could achieve is getting the first level (MasterTableView) to provide expand/collapse functionality.
Ideally we want to programmatically implement this (self-joining hierarchical grid) - so we have full control over all columns and also so we can unit test the code. And also we'd like to be able to create our own class which inherits from RadGrid - so we can encapsulate all this behaviour.
However in the interest of delivering a working solution we'll use any method - and currently the declarative seems the only way that this works. So the outstanding problems are that it is creating the columns in the incorrect sequence (setting column.OrderIndex within CategoryOnColumnCreated does not work) and the columns are not in alignment.
Any suggestions (and ideally an example of how to do this programmatically).
Thanks again
Tim
0
Accepted
Hi Tim,
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I created an example showing you how to create self-referencing hierarchy with RadGrid when the control is created programmatically inside the PageInit event handler.
You can find the project attached to this forum post. I suggest you to have a look at this help article as well.
Best regards,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Tim
Top achievements
Rank 1
answered on 06 Aug 2008, 02:20 AM
Brilliant - this is just what I needed - thanks so much!!!
The reason it didn't work for us is that we were trying to implement this within a user control that inherited from RadGrid. This seemed to be the problem. Once I converted this across to a standard class, inheriting from RadGrid, it worked!
Tim
The reason it didn't work for us is that we were trying to implement this within a user control that inherited from RadGrid. This seemed to be the problem. Once I converted this across to a standard class, inheriting from RadGrid, it worked!
Tim