Hierarchical presentation style for DataGrid

  • Thread starter Thread starter Lee Gillie
  • Start date Start date
L

Lee Gillie

I have bound datagrid to a dataset with a datarelation defined between
work orders and line items of those work orders.

The default navigation style is to present the [+] at each work order.
You expand, and it shows the name of the datarelation in a new line,
that is shown as a hyperlink. You must THEN click the hyperlink and then
it clears the data grid display, shows the parent work order data at the
top, and then a grid of columns for the line item.

I have seen grids show subordinate records on the same "page" as their
master records, with column headings for the expanded area appropriate
for the line items. How is this done?
 
I don't know if this is an option for you but Infragistics UltraGrid does
this nicely with no code.

WR
 
Hierachical Data with the provided windows forms grid control is not
possible. You may have more luck using a tree view in conjunction with a
datagrid. You will probably want to buy a third party control unless you
are up to the challenge.

btw- if you succeed, I could help you get it published. Contact me through
my blog.

--
Tom Krueger

My Blog - http://weblogs.asp.net/tom_krueger
Smart Client DevCenter - http://msdn.microsoft.com/smartclient/
Mobile DevCenter - http://msdn.microsoft.com/mobility

This posting is provided "as is" with no warranties and confers no rights.

WhiskyRomeo said:
I don't know if this is an option for you but Infragistics UltraGrid does
this nicely with no code.

WR

Lee Gillie said:
I have bound datagrid to a dataset with a datarelation defined between
work orders and line items of those work orders.

The default navigation style is to present the [+] at each work order.
You expand, and it shows the name of the datarelation in a new line,
that is shown as a hyperlink. You must THEN click the hyperlink and then
it clears the data grid display, shows the parent work order data at the
top, and then a grid of columns for the line item.

I have seen grids show subordinate records on the same "page" as their
master records, with column headings for the expanded area appropriate
for the line items. How is this done?
 
Tom said:
Hierachical Data with the provided windows forms grid control is not
possible. You may have more luck using a tree view in conjunction with a
datagrid. You will probably want to buy a third party control unless you
are up to the challenge.

btw- if you succeed, I could help you get it published. Contact me through
my blog.

I beg to differ - .NET Windows Forms Datagrid does display, and provide
for fully automatic navigation of hierarchical data. It is just not
documented well.

I've done two different ways now. I am at home now, and my code is at
work, so trying to recall the details...

My first was binding to a list I made myself. I think datagrid documents
IList and IEditable for this. One property of the list item was a
collection of homogenous items. When binding this property the data grid
will show the data hierarchically (IList master table / collection for
details table). IIRC the subordinate data of the collection's items was
an in-place representation.

The second approach was to use a dataset with a relationship defined
between two tables. IIRC I bound to the master table, or maybe it was
the relationship?? - I don't have the code here at home to consult. In
this way I had much less code to write, but I don't like the way it
jumps to a detail page, rather than displaying the detail inline. But
navigation between the item level and master level displays is
reasonable. I suspect in this way (with the hyperlink to subordinate
list) one could bind many different related tables and navigate between
them. But since I have only two tables I want to represent, it seems
like a superfluous layer of navigation.

I'll bet there are even more ways to do it though.

I am very familiar with the tree-view approach, and my complaint is the
inability to manage columnar representations with it. Synchronizing a
tree and grid would be possible, but seems problematic. A grid with
hierarchical abilities fits the needs for my current project better.

- Lee
 
Hi Lee,

First I would like to apologize, I wasn't clear in my response. I said
"Hierachical Data with the provided windows forms grid control is not
possible." This statement is false. You are correct that the Datagird will
handle hierarchical data. However, I was responding to your need of wanting
the Hierarchical data to show up INLINE with the parent data. So I should
have responsed "Displaying hierarchial data INLINE using the provided
windows forms grid control is not possible." I generally don't like stating
that something is not possible. As a developer I know that pretty much
anything is possible given time and money. So it very well may be possible,
however, it will be difficult. I also say this because I have wanted this
functionality myself for two years and have asked many people if they know
how to do this and the answer is no. It may be that someone has modified
the grid or has created a grid control that does this. Check out
www.CodeProject.com.

Again, if you do figure out how to display hierachical data INLINE using the
provided grid control I will be happy to help you publish an article on it.

Happy Hunting,

Tom
 
Thanks, Tom -

Sometimes even if the answer to question is "can't be done", it is still
helpful. We all seem to find plenty of reasons to bang our heads on the
wall, and I like to think that such a response may save some bruising to
some tender developer heads, such as mine!

I may return to this as a focus for research, but for the moment I am
going to move on.

Thanks for taking time to share your wisdom.

Best regards - Lee Gillie
 
I agree and have plenty of bruises myself.


Lee Gillie said:
Thanks, Tom -

Sometimes even if the answer to question is "can't be done", it is still
helpful. We all seem to find plenty of reasons to bang our heads on the
wall, and I like to think that such a response may save some bruising to
some tender developer heads, such as mine!

I may return to this as a focus for research, but for the moment I am
going to move on.

Thanks for taking time to share your wisdom.

Best regards - Lee Gillie
Hi Lee,

First I would like to apologize, I wasn't clear in my response. I said
"Hierachical Data with the provided windows forms grid control is not
possible." This statement is false. You are correct that the Datagird
will handle hierarchical data. However, I was responding to your need of
wanting the Hierarchical data to show up INLINE with the parent data. So
I should have responsed "Displaying hierarchial data INLINE using the
provided windows forms grid control is not possible." I generally don't
like stating that something is not possible. As a developer I know that
pretty much anything is possible given time and money. So it very well
may be possible, however, it will be difficult. I also say this because
I have wanted this functionality myself for two years and have asked many
people if they know how to do this and the answer is no. It may be that
someone has modified the grid or has created a grid control that does
this. Check out www.CodeProject.com.

Again, if you do figure out how to display hierachical data INLINE using
the provided grid control I will be happy to help you publish an article
on it.

Happy Hunting,

Tom



Tom Krueger [MSFT] wrote:

Hierachical Data with the provided windows forms grid control is not
possible. You may have more luck using a tree view in conjunction with
a datagrid. You will probably want to buy a third party control unless
you are up to the challenge.

btw- if you succeed, I could help you get it published. Contact me
through my blog.


I beg to differ - .NET Windows Forms Datagrid does display, and provide
for fully automatic navigation of hierarchical data. It is just not
documented well.

I've done two different ways now. I am at home now, and my code is at
work, so trying to recall the details...

My first was binding to a list I made myself. I think datagrid documents
IList and IEditable for this. One property of the list item was a
collection of homogenous items. When binding this property the data grid
will show the data hierarchically (IList master table / collection for
details table). IIRC the subordinate data of the collection's items was
an in-place representation.

The second approach was to use a dataset with a relationship defined
between two tables. IIRC I bound to the master table, or maybe it was the
relationship?? - I don't have the code here at home to consult. In this
way I had much less code to write, but I don't like the way it jumps to a
detail page, rather than displaying the detail inline. But navigation
between the item level and master level displays is reasonable. I suspect
in this way (with the hyperlink to subordinate list) one could bind many
different related tables and navigate between them. But since I have only
two tables I want to represent, it seems like a superfluous layer of
navigation.

I'll bet there are even more ways to do it though.

I am very familiar with the tree-view approach, and my complaint is the
inability to manage columnar representations with it. Synchronizing a
tree and grid would be possible, but seems problematic. A grid with
hierarchical abilities fits the needs for my current project better.

- Lee
 
Back
Top