Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Row numbering for table export (Read 4461 times)
Paul Walters
Full Member
*
Offline



Posts: 267

Row numbering for table export
Nov 04th, 2010, 8:54am
 
I am exporting to HTML.  The export has several tables.  The content for each table comes from an agent in the TBX document.  There are four agents, and they are children of a container at the top level of the TBX document.  The notes collected by each agent are the rows of the table for that agent.

The first column of each table is the row number for that item.  I am using the "sectionNumber" attribute to populate the cell for that column in each row.  Because the container for the agents is at the top level of the TBX document, and there are four agents, and each agent collects notes, my "sectionNumber" values are

For table (i.e. agent) 1: 1.1.1, 1.1.2 ... 1.1.n
For table 2: 1.2.1, 1.2.2 ... 1.2.n

and so forth.

This is working, but seems a kludge of sorts.  Ideally, I would like a mechanism to number the rows from 1 to n (without the hierarchy), and restart the numbering in each table (that is, for the notes collected in each agent).

Is there a way?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Row numbering for table export
Reply #1 - Nov 4th, 2010, 9:40am
 
OK so you've an arrangement like:

Table export container
   Agent for row 1 data
   Agent for row 2 data
   Agent for row 3 data
   Agent for row 4 data
...etc.


So the container exports something like:
Code:
<table>
^children(table-row)^
</table> 


The 'table-row' code which exports the agent is like this:
Code:
<tr>
<td>^value($SiblingOrder)^</td>
^children(other-columns)^
</tr> 


The contents of the agent are exported using 'other-columns', something like:
Code:
<td>^text^</td> 


or
Code:
<td>^value($SomeAttribute)^</td> 



So, for:

Table export container
  Agent for row 1 data
     XX1
     XX2  
   Agent for row 2 data
     YYA
     YY5
...etc.


and using $Name for 'other-columns', we get:
Code:
<table>
<tr>
<td>1</td>
<td>XX1</td>
<td>XX2</td>
</tr>
<tr>
<td>2</td>
<td>YYA</td>
<td>YY5</td>
</tr>
</table> 


Of course, you can add in other HTML tag attributes as needed and fiddle with white space/indenting for the source but the above seem to reflect your plan. Does that help?

Back to top
 
« Last Edit: Nov 4th, 2010, 9:48am by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Paul Walters
Full Member
*
Offline



Posts: 267

Re: Row numbering for table export
Reply #2 - Nov 4th, 2010, 10:47am
 
Mark, firstly - ^value($SiblingOrder)^ does the trick.  It is exactly what I needed.

(I had tried ^getFor(this,$SiblingOrder)^, and that did not work.)

For documentation clarity, my structure is as follows, and I've constructed export templates similar to your suggested ones, but adjusted for this slightly different structure:


Report container
--- Agent for Table 1
-------Note for row 1 data
-------Note for row 2 data
-------etc.
--- Agent for Table 2
-------Note for row 1 data
-------etc.
--- etc.

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Row numbering for table export
Reply #3 - Nov 4th, 2010, 11:13am
 
Ah, I'd slightly missread your structure but looks like we got there. Watching line returns at the end of the last line of template code and judicious use of ^indent^ will also give you nice clean code. Though I did test my solution before posting, it was done for speed not beauty as I had my head in something else at the time.

Export codes pre-date the use of $ attribute references, so either ^get(SiblingOrder)^ or ^getFor(this,SiblingOrder)^ should work (I just tested the first of those. This is why moving to using ^value($AttrName)^ makes for more consistent usage, with ^tilte^ and ^text^ for $Name and $Text being important exceptions.

Indeed, for the same issue of stylistic consistency with attribute references, the new $StrAttr.contains(pattern) operator replaces (in v5.7.0+) the StrAttr(pattern) query operator whose $-less form often trips up us users.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print