Categories > TinyButStrong general >

Can i combine headergrp fields ?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: kle_py
Date: 2009-06-26
Time: 20:05

Can i combine headergrp fields ?

My (simplified) html template is:
<tr>
    <td colspan="3" class="tr_subhead">[blk1.dpto] - [blk1.sector;block=tr;headergrp=sector]: </td>
</tr>

<tr>
     <td><div>[blk1.nombre]</div></td>
     <td><div>[blk1.apellido]</div></td>
     <td><div>[blk1.phone]</div></td>
</tr>

I would like to get a listing-table which creates a new header, for each group of working sections.
Now i have a special "search" condition, which gives me a problem, when there is a list of persons in different dptos, however same named "sub"-sections!
In this case the list is shown as if the persons belong to the same sub-section.

I could not find a way to "combine" the 2 relevant fields which represent my "real" header group.

Example output:
<tr>
    <td colspan="3" class="tr_subhead">FINANCIERO  - CENTRAL:</td>
</tr>

<tr>
<td><div>ADOLFO</div>&nbsp;</td>
<td><div>LOPEZ</div>&nbsp;</td>
<td><div>phone nr</div>&nbsp;</td>
</tr>

<tr>
<td><div>JAVIER</div>&nbsp;</td>
<td><div>LOPEZ</div>&nbsp;</td>
<td><div>phone nr</div>&nbsp;</td>
</tr>

However i would like to have:
<tr>
    <td colspan="3" class="tr_subhead">FINANCIERO  - CENTRAL:</td>
</tr>

<tr>
<td><div>ADOLFO</div>&nbsp;</td>
<td><div>LOPEZ</div>&nbsp;</td>
<td><div>phone nr</div>&nbsp;</td>
</tr>

<tr>
<td colspan="3" class="tr_subhead">INFORMATICA - CENTRAL:</td>
</tr>

<tr>
<td><div>JAVIER</div>&nbsp;</td>
<td><div>LOPEZ</div>&nbsp;</td>
<td><div>phone nr</div>&nbsp;</td>
</tr>


Currently my workaround is using an additional row:
<tr>
    <td colspan="3" class="tr_invisible"><div>[blk1.dpto;block=tr;headergrp=dpto]</div></td>
</tr>
which i set invisible using CSS style,

however i would like if it possible to do this the "direct" way, without need of invisible elements on the html side.

Thank You..
By: TomH
Date: 2009-06-26
Time: 20:54

Re: Can i combine headergrp fields ?

Hello,

You can do this directly - and simply with TBS headergroup - a second headergroup defined inside of a first headergroup

I won't try to re-write your code - instead hear is the source code from my example application at http://tomhenry.us/tbs3/ the application named "My Inventory Demo"

The PHP which gets the rows - must do the 'order by' for the headergroup fields correctly.
$sql="select id,vendorid,vendorsku,category,description,details,retailprice,ourprice,units from $table order by category,vendorid,vendorsku";

$query = $db->get_results($sql);

$TBS->MergeBlock('blk1', $db);

The headergroup (two in this case) html/template code for the above is...
<table bgcolor="#FFFFC4" width="95%" cellspacing=0 cellpadding=2 border=[var.border] >

         <tr><td bgcolor="#E5E5E5" class='reverse' colspan=99>     <font face="Comic Sans MS,EraserDust,Helvetica,sans-serif" size="+0" color="#800000"><b>[blk1.category;block=tr;headergrp=category]</font></td></tr>
       
        <tr><td bgcolor="#FFFF97" colspan=2> Vendor:<b>    [blk1.vendorid;block=tr;headergrp=vendorid]</b></td>
        <td bgcolor="#FFFF97" class='reverse' colspan=1>SKU</td>
        <td bgcolor="#FFFF97" class='reverse' colspan=1>Units</td>
        <td bgcolor="#FFFF97" class='reverse' align=right>Price</td>
        <td bgcolor="#FFFF97" class='reverse' align=right> List &#160;  &#160; </td></tr>
       
        <tr><td></td><td class='resultrows' valign=top>[blk1.description;block=tr;headergrp=vendorsku]</td>
        <td class='resultrows'><a href="[var..script_name]?id=[blk1.id]">[blk1.vendorsku]</a></td>
        <td class='resultrows' valign=top align=left width=10>[blk1.units]</td>
        <td class='resultrows' valign=top align=right>[blk1.ourprice]</td>
        <td class='resultrows' valign=top align=right>[blk1.retailprice] &#160;  &#160; </td>
        </tr>

Hope that helps,
TomH
By: TomH
Date: 2009-06-26
Time: 20:57

Re: Can i combine headergrp fields ?

Sorry, just to be clear, I should have mentioned...

The first headergroup in my example is "category" field

The second headergroup (inside the first) is "vendorid"
By: kle_py
Date: 2009-06-26
Time: 22:18

Re: Can i combine headergrp fields ?

Thanks TomH,

well.
I think Your solution is equivalent with what i actually have now (using my workaround) !

And It seems to me that the second group is NOT inside, the first header, just AFTER..

Only I make the first row (in Your example: containing [blk1.category;block=tr;headergrp=category] similar to "dpto" in my example) invisible, because i would like to have all (Category+vendor)-info as a title in a single row!
Therfore i have the equivalent of [blk1.category] (equivalent of "dpto") as an additional info in the following line with headergrp (your "vendorid", my "sector").
By: Skrol29
Date: 2009-06-27
Time: 23:14

Re: Can i combine headergrp fields ?

Hi,

Another solutrion is to create in your SQL a new column which is a concatenation of sector+'/'+dpto. And use this column for the headergrp.

If data doesn't come from SQL, you can create the column at the PHP side when the data are merged using a custom function that goes with parameter "ondata".
By: kle_py
Date: 2009-06-28
Time: 00:12

Re: Can i combine headergrp fields ?

Thanks Skrol,

I think this i will do, sounds like what i searched for.
I will add a new combined column in SQL, and use this for headergrouping, although without displaying it itself..

Thank You