Inherited DataGrid layout problem

J

James Cohen

Hi group, your help with this would be very much appretiated. I am trying to
roll out my own datagrid, which functionally would work JUST like the built
in one - in fact my aim is to swap many DataGrid's out for my custom one so
the exposed columns/properties should be the same.

Because of this requirement to swap out normal datagrid's for my new one the
obvious choice for me was to inherit from DataGrid and manipulate the layout
at runtime (more on what im trying to do below), when I got stumped I tried
the other way which was to inherit from BaseDataList but I had problems here
trying to figure out what Create & Prepare ControlHeirachy methods were for.

So background aside, here's what Im trying to make; A datagrid that has a
fixed header. fixed footer and fixed pager... but the grid portion scrolls.
In my head, and with a mockup in HTML it works a charm. You have an outer
table with 1 columns and 4 rows. Top row has a layer set to hide overflowing
elements, this layer contains a table with the DataGrid's header. 2nd row
has a layer set to scroll overflowing elements, this layer contains the grid
portion of the datagrid. 3rd row, hides overflow contains table with footer
and of course the bottom row would be the pager.

My problem is ive hit a brick wall! For the life of me I cannot work out how
to change the control heirachy of a DataGrid. I can capture the DataGridItem
when they are created, I can create my outer table, I can even add the
DataGridItem in its correct place (it is just an Inherited TableRow right?).
However when I look at my trace the datagrid is made up of a "DataGridTable"
at Controls[0] (which I cant even find a definition for). All the
subcontrols are standard.

Through some intensive tracing I found that it was the method
CreateControlHeirachy that was building up the controls as far as I couild
see. The problem is that this method also called CreateColumnSet, which
takes a pagedDataSource as parameter 1 - this is not accessible to an
inherited datagrid :( |brick wall

So i tried creating a web control that was a mimic of DataGrid. It inherited
from BaseDataList and exposed every property and method that a datagrid
does.... problem is DataGridColumnCollection takes a DataGrid owner
parameter 1 which i cant supply.

So my question for any experts out there (seeing as Im not giving up on this
hehe) is do I a) stick with my original method of inheriting DataGrid and if
so where did I go wrong? or b) Stick with inheriting BaseDataList, make my
own version of DataGridColumnCollection etc, maintain my own pagedDataSource
etc etc - is this way even possible?

I know how I could do this, but I dont like it...... I could wrap a DataGrid
in an inherited DataGrid, use that for just the grid row (with header,
footer etc turned off) and build the header footer etc myself from the
supplied columns in the aspx. However I dont like the sound of this way much
at all... It reminds me too much of VB and isnt nearly OO enough for my mind
:)

Sorry for the long post guys and gals.
 
M

Memi Lavi

James Cohen said:
Hi group, your help with this would be very much appretiated. I am trying to
roll out my own datagrid, which functionally would work JUST like the built
in one - in fact my aim is to swap many DataGrid's out for my custom one so
the exposed columns/properties should be the same.

Because of this requirement to swap out normal datagrid's for my new one the
obvious choice for me was to inherit from DataGrid and manipulate the layout
at runtime (more on what im trying to do below), when I got stumped I tried
the other way which was to inherit from BaseDataList but I had problems here
trying to figure out what Create & Prepare ControlHeirachy methods were for.

So background aside, here's what Im trying to make; A datagrid that has a
fixed header. fixed footer and fixed pager... but the grid portion scrolls.
In my head, and with a mockup in HTML it works a charm. You have an outer
table with 1 columns and 4 rows. Top row has a layer set to hide overflowing
elements, this layer contains a table with the DataGrid's header. 2nd row
has a layer set to scroll overflowing elements, this layer contains the grid
portion of the datagrid. 3rd row, hides overflow contains table with footer
and of course the bottom row would be the pager.

My problem is ive hit a brick wall! For the life of me I cannot work out how
to change the control heirachy of a DataGrid. I can capture the DataGridItem
when they are created, I can create my outer table, I can even add the
DataGridItem in its correct place (it is just an Inherited TableRow right?).
However when I look at my trace the datagrid is made up of a "DataGridTable"
at Controls[0] (which I cant even find a definition for). All the
subcontrols are standard.

Through some intensive tracing I found that it was the method
CreateControlHeirachy that was building up the controls as far as I couild
see. The problem is that this method also called CreateColumnSet, which
takes a pagedDataSource as parameter 1 - this is not accessible to an
inherited datagrid :( |brick wall

So i tried creating a web control that was a mimic of DataGrid. It inherited
from BaseDataList and exposed every property and method that a datagrid
does.... problem is DataGridColumnCollection takes a DataGrid owner
parameter 1 which i cant supply.

So my question for any experts out there (seeing as Im not giving up on this
hehe) is do I a) stick with my original method of inheriting DataGrid and if
so where did I go wrong? or b) Stick with inheriting BaseDataList, make my
own version of DataGridColumnCollection etc, maintain my own pagedDataSource
etc etc - is this way even possible?

I know how I could do this, but I dont like it...... I could wrap a DataGrid
in an inherited DataGrid, use that for just the grid row (with header,
footer etc turned off) and build the header footer etc myself from the
supplied columns in the aspx. However I dont like the sound of this way much
at all... It reminds me too much of VB and isnt nearly OO enough for my mind
:)

Sorry for the long post guys and gals.

Hi.

We had the same problem. The way we did the scrolling thing was to
hook into the Render method, grab the produced HTML, pull out the
header and footer and wrap them in seperate tables. It works like
charm.

Good Luck!
 
J

John Saunders

James Cohen said:
Hi group, your help with this would be very much appretiated. I am trying to
roll out my own datagrid, which functionally would work JUST like the built
in one - in fact my aim is to swap many DataGrid's out for my custom one so
the exposed columns/properties should be the same.

Because of this requirement to swap out normal datagrid's for my new one the
obvious choice for me was to inherit from DataGrid and manipulate the layout
at runtime (more on what im trying to do below), when I got stumped I tried
the other way which was to inherit from BaseDataList but I had problems here
trying to figure out what Create & Prepare ControlHeirachy methods were
for.

Would it work for you to handle the header, footer and pager yourself, and
to tell the base DataGrid that there should be no header, footer, or pager?
Then render your own surrounding table around the DataGrid's own output.

I wouldn't want to make assumptions about what HTML a DataGrid renders by
screwing around with its output in Render...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top