Inherited DataGrid layout problem

Discussion in 'ASP .Net Building Controls' started by James Cohen, Nov 8, 2003.

  1. James Cohen

    James Cohen Guest

    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.
    James Cohen, Nov 8, 2003
    #1
    1. Advertising

  2. James Cohen

    Memi Lavi Guest

    "James Cohen" <> wrote in message news:<3a5rb.382$>...
    > 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!
    Memi Lavi, Nov 8, 2003
    #2
    1. Advertising

  3. "James Cohen" <> wrote in message
    news:3a5rb.382$...
    > 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...
    --
    John
    John Saunders, Nov 8, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Spiewak
    Replies:
    3
    Views:
    3,134
    Rick Spiewak
    Aug 26, 2003
  2. RobertH
    Replies:
    1
    Views:
    710
    Steve C. Orr [MVP, MCSD]
    Nov 4, 2003
  3. NWx
    Replies:
    4
    Views:
    2,951
    Kevin Spencer
    Feb 19, 2004
  4. Replies:
    1
    Views:
    564
    John Timney \(MVP\)
    Jun 19, 2006
  5. 7stud --
    Replies:
    11
    Views:
    388
    7stud --
    Nov 9, 2007
Loading...

Share This Page