A table with subheaders

A table with subheaders

  
Hi,
I am new to Agile Platform. I have just started my first project.
 
I need to create a table with subheaders. Say there wil be a table like this:

Name | Value
-------------------
AAA     | 1
AAA     | 2
AAA     | 3
BBB    | 100
BBB    | 200

And this table when displayed should have two subheaders: AAA and BBB. So that two sections of the table related to AAA and BBB data can be easily disingueshed by the user.
The table inself is fetched using an Advanced SQL query.

I would you be extremly thankful to anyone who could point me to the right direction.

Regards,
Andrey
Hy Andrey, 

is that what you would like to see in the webscreen as the result of the query?

Name | Value
-------------------
AAA     | 1
            | 2
            | 3
BBB    | 100
            | 200
Yes. Something like it.

Alternatively it could be

AAA
--------------
   1
   2
   3
BBB
--------------
   100
   200

this would be even better, but your variant also works.
Do you really need it to be a single table?

I'm asking this, because if you don't, you might want to consider using the ListRecords control, instead of the TableRecords.
With the ListRecords, you can just list AAA and BBB on it, then use a WebBlock that receives the "type" as input and lists the actual values for that "type".
ListRecords are a lot more flexible than TableRecords, because they allow you to control all the content and structure inside them.

In case you need it to be in a single table, you'll probably have to inject some HTML using an Expression with "Escape Content: No".

Eg. This is how  the HTML code for your original list might look like
<table>
<tr>
<td>Name</td>
<td>Value</td>
</tr>
<tr>
<td>AAA</td>
<td>999</td>
</tr>
<tr>
<td>BBB</td>
<td>999</td>
</tr>
</table>

You will need to inject some HTML in the first line of every table, and at every type change:
  • CurrentNowNumber = 0 or (List.CurrentNowNumber > 0 and List.Current.Type.Id <> List.[List.CurrentRowNumber -1].Type.Id)
Now using that condition, you might want to inject something like (using that non escaped Expression)
  • List.Current.Type.Label + "</td><td></td></tr><tr><td>"
Make sure you put that inside the first cell, and before all other content in it. (You also won't need that expression you had showing the "Name" label, because that value will be injected in the "header".
This will add you a new line before those, and you'll end up with something like:

<table>
<tr>
<td>Name</td>
<td>Value</td>
</tr>
<tr>
<td>AAA</td>
<td></td>
</tr>
<tr>
<td></td>
<td>999</td>
</tr>
<tr>
<td>BBB</td>
<td></td>
</tr>
<tr>
<td></td>
<td>999</td>
</tr>
</table>

Sorry if it's a bit confusing, couldn't see a way of explaining it better using only text.

I'd stick to the ListRecords method, since you're new to the platform, because injecting HTML might turn your code into an unreadable mash of expressions with html in it. :)

To make it simpler and to achieve the output Ricardo talked about (no html or ListRecords), just put your "Label" expression inside an If block with that other condition,
  • TableRecords.List.CurrentNowNumber = 0 or (TableRecords.List.CurrentNowNumber > 0 and TableRecords.List.Current.Type.Id <> TableRecords.List.[TableRecords.List.CurrentRowNumber -1].Type.Id)
This will make your label show only on the first line of a group of value. Just make sure your source recordlist is sorted By Type.
Thank you for this amazingly detailed answer! ListRecords solution is exactly what I need! But I'll also try your other suggestions just to play with the platform and see how it goes. Thanks! Regards
Hi

I'm new to the boards, but I am trying to do the same thing, except that I have three columns I would like to group by.

My example is as follows

Column 1 -> Column 2 -> Column 3 - Column 4
Record 1
Record 2
Record 3

The user needs to select Columns 1 through 4, (the values are selected from 4 separate views),
The first two fields of records 1 through 3 are an id, and a description (a view based on the selections in Column 1 through 4) and additional data specific to each row is entered in remaining fields for each record.

Hopefully that makes sense.  Let me know if you need more clarification.

Thanks

Hi Matt,

I have re-read your post a few times and I'm still missing some of the details of what you are trying to accomplish. A few questions:

1) You mention specifically 3 records: was this by way of an example, or will your table really have only 3 rows? In that case, can you clarify what is the semantics of these specific rows?
2) Do your doubs focus on how to SELECT the necessary columns from multiple tables from the Database into a usable Record List (i.e. the platform's in-memory table) or on how to DISPLAY the necessary data into a suitable tabular form in the screen?

Regards,


Miguel
Hi Miguel

Basically what we're doing is a timesheet application

Column 1 - Project - User will select the project (selected from project table)
Column 2 - Manufacturing Order - User will select from a list of valid MOs for the project (selected from MO table)
Column 3 - Manufacturing Order Row - User will select from a list of valid MO Rows for the current project and current manufacturing order (Selected from MO sub orders table)
I was a little off on the number of columns used in grouping, there are three, not four

These selections will create rows where the user will enter the hours worked on the project.  We would like to be able to group by Project, then by MO, and finally by MO sub order.
Here is a sample of what we are trying to achieve:

Project No
      MO Number
           MO Row Number
                  Operation 1 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31
                  Operation 2 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31
           MO Row Number
                  Operation 1 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31
                  Operation 2 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31
      MO Number
           MO Row Number
                Operation 1 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31
                Operation 2 | Hours_day_01 | Hours_Day_02 | ... | Hours_Day_31

I hope this helps.
Let me know if  you have any more questions.

Matt
Hi Matt,

I knocked together a quick eSpace with a data model similar to what I think you wanted, and a screen that does a query joining up the 4 tables and then displays the output in a cascaded form similar to the one you were looking.

If you look into the SeedData action (that creates some data) you'll see that I actually create a second project, but since it has no MO's etc, the query on the screen will not display it.

Hope this is enough to get you on your way. :) Let me know if you have doubs.

Cheers,


Miguel
Thanks Miguel

That helped a lot.

Matt