Render Data By Group

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default Render Data By Group

    I've been trying to come up with a way to use the built in ASP.NET
    controls to design something that displays the results of a database
    query by group like is possible in an Access report to, for example,
    display a list of managers and all of their employees. For example:

    Type 1
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    Type 2
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    Type 3
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    Column 1, Column 2, Column 3
    [...]

    So far, I have come up short on ideas to implement this cleanly using
    the ASP.NET controls. A friend of mine suggested a Repeater with
    another Repeater nested inside of it; however, it just didn't seem like
    a clean way.

    I've considered developing my own custom server control that extends the
    CompositeDataBoundControl class, but even doing this, I couldn't think
    of a clean way of doing it without requiring two DataSource properties
    (one for the Managers and another for the Employees).

    I'm sure others have run across a similar situation in the past; but, I
    haven't had any luck locating any examples.

    Does anybody have any suggestions?

    Thank you in advance,

    --
    Sean
    senfo Guest

  2. Similar Questions and Discussions

    1. Render XML
      Hi I want to render a XML file as it is rendered in Internet Explorer. I should be able to expand/collapse its node and copy it. Can any one...
    2. May 29 Sydney Developers Group study group
      On Monday 29th May, we'll be studying Actionscript 3. Please read the articles prior to the meeting (see <a target=_blank...
    3. cfgrid inside a <cfoutput query="myQuery" group="GROUP">
      Is it possible to use a cfgrid inside a cfoutput with a query and a group. When I try do that I get the following error: INVALID_CHARACTER_ERR:...
    4. Is it possible to group data with a header?
      I have been asked to create different reports. For example Events by location. This is easy but now they want me to group the locations . For...
    5. Binding a Radio Button Group to a Data Holder
      I'm fairly new to components and recently I had some trouble binding a radio button group to a data holder and saw that other had as well. This may...
  3. #2

    Default Re: Render Data By Group

    Hey Sean,
    I think the CompositeDataBoundControl is definitely the way to go- and
    you don't need two datasource properties. The trick here is loose
    casting in the CreateChildControl function. What you want to do is
    enumerate through the datasource like you would do for a flat control,
    and add a row or whatever container you wanted for that primary row in
    the datasource. Then, when you have your enumerated element, you can
    see if that implements the IList, IListSource, or the IEnumerable
    interface. If it does, you can get an enumerator from that element and
    loop it just like you were doing for the primary datasource. With this
    secondary list you can build your sub grid.

    You may want to add some properties to help the composite control find
    the child controls in the datasource. Say, if the datasource is a
    dataset you can add some props to help the CreateChildControl function
    find relationships with datatables to access sub data.

    Here's some psuedocode:

    Enumerator ie = this.DataSource.GetEnumerator();
    foreach(element in ie)
    {
    row = BuildRow();
    if(element is IEnumerator)
    {
    IEnumerator AnotherEnumerator = element.GetEnumerator();
    BuildTableInRow(row, AnotherEnumerator); //This Builds the sub
    table
    }


    senfo wrote:
    > I've been trying to come up with a way to use the built in ASP.NET
    > controls to design something that displays the results of a database
    > query by group like is possible in an Access report to, for example,
    > display a list of managers and all of their employees. For example:
    >
    > Type 1
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > Type 2
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > Type 3
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > Column 1, Column 2, Column 3
    > [...]
    >
    > So far, I have come up short on ideas to implement this cleanly using
    > the ASP.NET controls. A friend of mine suggested a Repeater with
    > another Repeater nested inside of it; however, it just didn't seem like
    > a clean way.
    >
    > I've considered developing my own custom server control that extends the
    > CompositeDataBoundControl class, but even doing this, I couldn't think
    > of a clean way of doing it without requiring two DataSource properties
    > (one for the Managers and another for the Employees).
    >
    > I'm sure others have run across a similar situation in the past; but, I
    > haven't had any luck locating any examples.
    >
    > Does anybody have any suggestions?
    >
    > Thank you in advance,
    >
    > --
    > Sean
    Michael Hamrah Guest

  4. #3

    Default Re: Render Data By Group

    Michael Hamrah wrote:
    > Hey Sean,
    > I think the CompositeDataBoundControl is definitely the way to go- and
    > you don't need two datasource properties. The trick here is loose
    > casting in the CreateChildControl function. What you want to do is
    > enumerate through the datasource like you would do for a flat control,
    > and add a row or whatever container you wanted for that primary row in
    > the datasource. Then, when you have your enumerated element, you can
    > see if that implements the IList, IListSource, or the IEnumerable
    > interface. If it does, you can get an enumerator from that element and
    > loop it just like you were doing for the primary datasource. With this
    > secondary list you can build your sub grid.
    >
    > You may want to add some properties to help the composite control find
    > the child controls in the datasource. Say, if the datasource is a
    > dataset you can add some props to help the CreateChildControl function
    > find relationships with datatables to access sub data.
    >
    > Here's some psuedocode:
    >
    > Enumerator ie = this.DataSource.GetEnumerator();
    > foreach(element in ie)
    > {
    > row = BuildRow();
    > if(element is IEnumerator)
    > {
    > IEnumerator AnotherEnumerator = element.GetEnumerator();
    > BuildTableInRow(row, AnotherEnumerator); //This Builds the sub
    > table
    > }
    >
    Hi Michael,

    Thank you very much for the response. I've been busy at work with my
    primary job (this question was in reference to a side project), so I
    haven't had an opportunity to try to implement it, yet.

    I think I have an idea of what you're suggesting, but I won't find out
    for sure until this evening or tomorrow evening. I'll definitely write
    back if I have any follow-up questions.

    Thank you again,

    --
    Sean
    senfo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139