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

[Solved] Hierarchical gridview

3 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alphons Mulders
Top achievements
Rank 1
Alphons Mulders asked on 03 Mar 2010, 11:22 AM
I have a gridview which has two defined columns:
<telerikGridView:RadGridView.Columns> 
  <telerikGridView:GridViewSelectColumn /> 
  <telerikGridView:GridViewColumn Header="Message" /> 
</telerikGridView:RadGridView.Columns> 

In code I bind a list of Obeservable Objects to the grid.
gdObjects.ItemsSource = lstCO; 

I now have a second list of Observable Objects (lstCO2) which holds the same type of Objects as bound to the grid.
I want this list to be the detailed row list. This second list can have the same Objects but with different PropertyValues. I want the user to be able to expand a row and see this second Object. Object has a Property Id to use to match it.

I can't define a template for this grid because this grid will be used for other objects too, the AutoGenerateColumns is set to True.

It the should look something like:

+ ObjectName1 | PropValue1 | PropValue2
- ObjectName2 | PropValue1 | PropValue2
  > ObjectName | OtherPropValue1 | PropValue2

Where > is the expanded row and + is still collapsed. Can someone put me in the right direction?

3 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 08 Mar 2010, 09:18 AM
Hello Alphons Mulders,

In order to suggest appropriate solution we require some additional information.

Is there some kind of correlation between itemssource and the child collection?
Will all rows  show the same data in its child details?
Can the child collection be the property of the object you are binding to?

All the best,
Tsvyatko
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
Alphons Mulders
Top achievements
Rank 1
answered on 09 Mar 2010, 04:52 PM
The parent and child lists are the same kind of objects in a list.
The parent list I create from an excel file which needs to be imported in a database.
Then I get a list of existing items based on one of the 'keyfields' in the objectlist. 

Maybe an example.

I have an excel file with persons:
Name, Lastname, Address

In the database I have a table Persons:
Id, Name, Lastname, Address

I first create a lstPersonsXLS where all Id's are null-guids
For each person in that list i try to find it by Name (suppose this is the 'key-field') to try to get an Id from the database.

All Id of persons in lstPersonsXLS will be filled where they can be found in the database.

Then I have this list of persons from the databse lstPersonsDB which holds all the found person.
So lstPersonsDB is actually a 'sub-set' of lstPersonsXLS. But each person.id (unique id) from lstPersonsDB can be found in lstPersonsXLS.
Suppose we have a person with name 'Alphons' in the Excel file with Address 'MyStreet 12, Hollywood' en the person already exists in the database 'Alphons' but with Address 'AnotherStreet 34, Dallas' I want to show a plus sign in the grid so I can expand it ans see both rows wit both values. That is to show the user the value from the Database and the value from the XLS file so he can decide if he want to update that row in the database.

btw My name is Iwan van Ee (developer for Alphons)
0
Tsvyatko
Telerik team
answered on 11 Mar 2010, 03:51 PM
Hello Iwan van Ee,

Since GridView cannot work directly with more than one collection some additional custom code is needed. In order this solution to work with custom data there is no column defined and I have added layer of data abstraction.

Please let me know if this works for you.

Sincerely yours,
Tsvyatko
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.
Tags
GridView
Asked by
Alphons Mulders
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Alphons Mulders
Top achievements
Rank 1
Share this question
or