This topic is locked

How to insert a subheader between groups of records

9/11/2007 1:24:02 PM
PHPRunner Tips and Tricks
admin

We'd like to modify the List page displaying subheader between groups of records. For instance we'd like to group our cars by make. Here is how it supposed to look in generated application:


PHPRunner 5.x-9.x

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet

{BEGIN grid_row}


right after {BEGIN grid_row} insert the following code snippet:



{BEGIN showheader}

<TR>

<TD colspan="20">

&nbsp;&nbsp;&nbsp;&nbsp;

<H1 style="padding: 0px 0px 5px 5px; color: rgb(82, 82, 82); font-family: Trebuchet MS, sans-serif; font-size: 150%; font-weight: bold;">

{$subheader}

</H1>

</TD>

</TR>

{END showheader}


3. Add BeforeMoveNextList (List page: After record processed) event:

global $make;

if($make!=$data["Make"])

{

$make=$data["Make"];

$row["showheader"]=true;

$row["subheader"]=$data["Make"];

}


PHPRunner4.2

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet

<!--{foreach from=$rowinfo item=row}-->


and insert the following snippet just after

{if $row.showheader}

<tr><td colspan=20>

&nbsp;&nbsp;&nbsp;&nbsp;

<h1>{$row.header}</h1>

</td></tr>

{/if}


3. Add BeforeMoveNextList (List page: After record processed) event:

global $make;

if($make!=$data["Make"])

{

$make=$data["Make"];

$row["showheader"]=true;

$row["header"]=$data["Make"];

}
J
jskewes 4/3/2008

Hi -

Can you expand a little on where step three is inserted?

This would be helpful on my current project.

Thanks,

/john

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet

    <!--{foreach from=$rowinfo item=row}-->
    and insert the following after this snippet

    --------------------------------------

    {if $row.showheader}

    <tr><td colspan=10>

    &nbsp;&nbsp;&nbsp;&nbsp;

    <h1>{$row.header}</h1>

    </td></tr>

    {/if}

    --------------------------------------
  3. Add BeforeMoveNextList event:

    --------------------------------------

    global $make;

    if($make!=$data["Make"])

    {

    $make=$data["Make"];

    $row["showheader"]=true;

    $row["header"]=$data["Make"];

    }



admin 4/4/2008

BeforeMoveNextList event.
You can find it on Events screen in PHPRunner.

S
spintz 4/11/2008

The actual event name in the GUI is called -
After record processed
The function name for that event ends up being -
BeforeMoveNextList
Would be nice if the names in the GUI matched up somehow, or properly represented what the actual function names end up being.

S
sluc23 2/18/2009

didn't say anything.

Works fine this example in the After record processed event (BeforeMoveNextList funtion)

Was a coding issue. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=37962&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Thanks.

ey, I need this feature also. But that event doesn't exist in PHPRunner v5.0 (766)

i tried this in Before Record Processedevent (BeforeProcessRowListfuntcion) but didn't work

Any update on this issue?
Thanks

C
Cjiggy0326 3/31/2009

I can't seem to get this to work either. Do we do a group by or a order by for the SQL query?

global $make;

if($make=$data["category"])

{

$make=$data["category"];

$row["showheader"]=true;

$row["header"]=$data["category"];

}
T
text 5/12/2011

Hi Sergey/Jane
This code works but because the table I am working on only contains id's is it possible to obtain the name which is held in another table but has the same id.
thanks
Richard

admin 5/12/2011

Richard,
I guess you can use a JOIN SQL Query to pull name from another table instead of ID.

T
text 5/12/2011

Of course ! Doh!
Thanks v much Sergey

L
laonian 10/17/2011

[size="4"]PHPr 6.0:
The code snippet does not work for me when I check off the "resizable table columns" in the Miscellaneous page.

[/size]

L
laonian 11/4/2011



[size="4"]PHPr 6.0:
The code snippet does not work for me when I check off the "resizable table columns" in the Miscellaneous page.

[/size]


[size="3"]works again in PHPRunner 6.0 build 9824.[/size]

O
Osric44 12/7/2011

I'm perplexed on how to go about solving a Sorting problem in code. I

have a group of rows with data listed across the columns ie.

Row 3, Employee Name, [Name Input], Sales Yr, Jan, Feb, Mar,

..etc,Total.

Row 4, Employee Number, [Number Input], Sales Yr, Jan, Feb, Mar, ...etc,

Total.

Row 5, Employee Status, [Status Input], Sales Yr, Jan, Feb, Mar, ...etc,

Total.

Row 6, Other Info, [Info Input], Sales Yr, Jan, Feb, Mar, ...etc, Total.

This segment of data gets repeated down the sheet for each employee. Is

there a way to sort by choosing the [Name Input] or by [Number Input]

and keep each segment together?

Thanks so much,

C
ckapote 2/28/2012

Great I use it and is working fine .
I need also to calculate SUB totals in same page see attached page

pls advise
image



PHPRunner4.2

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet
    and insert the following snippet just after
  3. Add BeforeMoveNextList (List page: After record processed) event:
    PHPRunner5.0 and later

    Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.
  4. Open List page in Visual Editor and switch to HTML mode
  5. Find the following code snippet
    and insert the following after this snippet
  6. Add BeforeMoveNextList (List page: After record processed) event:

D
Dingoboy 5/14/2013

.

I
indigo 7/5/2013

Hi,
This works in latest PHPR.

  1. Is it possible to have collapsible groups with only row header visible and when clicked, it expands into records?
  2. Or, Is it possible to create 'tabs' instead of static rows to create these groups on List page?

M
mhollibush 8/17/2016

I love this trick.
I am wondering though, if the $data is a numeric value from another table, how can you get the actual wording instead of the value
Here is what I am trying to do
global $make4;

if($make4!=$data["EventId"])

{

$make4=$data["EventId"];

$row["showheader4"]=true;

$row["header4"]=$data["EventId"];

}
I need this to pull the "Title" from the Event Table based on the EventId

S
smez 2/13/2019

Hi Sergey,
Is it possible to do this in PHPR 10?
Thanks
Graeme



We'd like to modify the List page displaying subheader between groups of records. For instance we'd like to group our cars by make. Here is how it supposed to look in generated application:

PHPRunner 5.x-9.x

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet

{BEGIN grid_row}


right after {BEGIN grid_row} insert the following code snippet:



{BEGIN showheader}

<TR>

<TD colspan="20">

&nbsp;&nbsp;&nbsp;&nbsp;

<H1 style="padding: 0px 0px 5px 5px; color: rgb(82, 82, 82); font-family: Trebuchet MS, sans-serif; font-size: 150%; font-weight: bold;">

{$subheader}

</H1>

</TD>

</TR>

{END showheader}


3. Add BeforeMoveNextList (List page: After record processed) event:

global $make;

if($make!=$data["Make"])

{

$make=$data["Make"];

$row["showheader"]=true;

$row["subheader"]=$data["Make"];

}


PHPRunner4.2

Lets assume we have a list page with cars listings ordered by make. We want to insert a group name (Make) in front of each group.

  1. Open List page in Visual Editor and switch to HTML mode
  2. Find the following code snippet

<!--{foreach from=$rowinfo item=row}-->


and insert the following snippet just after

{if $row.showheader}

<tr><td colspan=20>

&nbsp;&nbsp;&nbsp;&nbsp;

<h1>{$row.header}</h1>

</td></tr>

{/if}


3. Add BeforeMoveNextList (List page: After record processed) event:

global $make;

if($make!=$data["Make"])

{

$make=$data["Make"];

$row["showheader"]=true;

$row["header"]=$data["Make"];

}


vin7102 2/14/2019

Graeme,
Yes it works perfectly in v10, I have done it a few times in my projects. Â

Just use the examples shown above for PHPRunner 5.x-9.x.
Regards,

Vince

S
smez 2/15/2019

Thanks Vince!



Graeme,
Yes it works perfectly in v10, I have done it a few times in my projects. Â

Just use the examples shown above for PHPRunner 5.x-9.x.
Regards,

Vince

S
smez 2/17/2019

After some experimenting I found that editing the html in PHPr 10 was generating errors elsewhere in my app. So I adapted this approach so I don't need to edit the html in editor.
In events > "After table initialised" add:



$_SESSION["subHeader"] = "";


Then in events > "List page: Before record processed" add:



$subHeader = $_SESSION["subHeader"];

if($subHeader!=$data["subHeaderField"])

{

// display subHeader if new

$_SESSION["subHeader"] = $data["subHeaderField"];

$subHeader = "<h4>".$data["subHeaderField"]."</h4>";

$data["displayField"] = $subHeader.$data["displayField"];

}


..which will show the subHeader above the displayField (set to View as HTML) only when the subHeader changes.
This is useful to me even though it is not as elegant as the solution provided for PHPr 9. To help clarify that checkbox selection is for the displayField (and not the subHeader) I have also added the following custom css for my list page:



.bs-gridrow td {

vertical-align: bottom !important;

}
S
smez 3/29/2019

My customised hack no longer applies. The latest maintenance release for PHPR 10.1 (18th March 2019 - build 32668) has added the new 'Group by' feature on the List page which solves this problem.
Elegance has been restored!

J
John 4/1/2019



My customised hack no longer applies. The latest maintenance release for PHPR 10.1 (18th March 2019 - build 32668) has added the new 'Group by' feature on the List page which solves this problem.
Elegance has been restored!


Question:You mention that this is included in v10.1(Build 32668). I see the "Group By" function in the Report but I do not see the "Group By" function anywhere in the list view. If possible would you show a screenshot of the function.
Pls advise

John