Skip to content

Instantly share code, notes, and snippets.

@avernet
Forked from anonymous/gist:314246
Created February 25, 2010 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avernet/315165 to your computer and use it in GitHub Desktop.
Save avernet/315165 to your computer and use it in GitHub Desktop.
Sorting in datatable
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:widget="http://www.orbeon.com/oxf/xml/widget"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:ev="http://www.w3.org/2001/xml-events">
<head>
<xforms:model>
<xforms:instance id="pack">
<packs xmlns="">
<pack>
<pid/>
<sta/>
<chans/>
<!-- views/ -->
<evid/>
<ml/>
<formats/>
<calib/>
<zero/>
<email/>
</pack>
</packs>
</xforms:instance>
<xforms:instance id="ojoins">
<result xmlns="">
<ojoin>
<site.lat>33.6688</site.lat>
<evid>14476736</evid>
<azimuth>142.279</azimuth>
<etype>l</etype>
<distance>41.024</distance>
<time>2009-06-19T15:30:37.010Z</time>
<ml>3.2</ml><lat>33.377</lat>
<site.sta>GVDA</site.sta>
<depth>13.4</depth>
<auth>SCSN</auth>
<etime>1245425437.01000</etime>
<lon>-116.403</lon>
<site.elev>1.341</site.elev>
<site.lon>-116.673</site.lon>
</ojoin>
<ojoin>
<site.lat>33.6688</site.lat>
<evid>14477816</evid>
<azimuth>309.791</azimuth>
<etype>l</etype>
<distance>78.083</distance>
<time>2009-06-21T14:29:33.410Z</time>
<ml>3.28</ml><lat>34.116</lat>
<site.sta>GVDA</site.sta>
<depth>17.6</depth>
<auth>SCSN</auth>
<etime>1245594573.41000</etime>
<lon>-117.324</lon>
<site.elev>1.341</site.elev>
<site.lon>-116.673</site.lon>
</ojoin>
<ojoin>
<site.lat>33.6688</site.lat>
<evid>14442392</evid>
<azimuth>113.621</azimuth>
<etype>l</etype>
<distance>96.452</distance>
<time>2009-04-08T22:04:02.360Z</time>
<ml>3.46</ml>
<lat>33.318</lat>
<site.sta>GVDA</site.sta>
<depth>4.1</depth>
<auth>SCSN</auth>
<etime>1239228242.36000</etime>
<lon>-115.723</lon>
<site.elev>1.341</site.elev>
<site.lon>-116.673</site.lon>
</ojoin>
</result>
</xforms:instance>
</xforms:model>
</head>
<body>
<h1>Test - Datatable, Sorting and Select with full appearance</h1>
<ol>
<li>After the page loads, notice the instancd &quot;pack&quot; in the Inspector </li>
<li>Select rows, clicking on the select in the column Select - notice that evid and ml match the row.</li>
<li>Now sort the table by Date, Ml, Distance, etc. </li>
<li>Again select rows and watch the pack instance in the Inspector</li>
<li>The values refer to the unsorted items.</li>
</ol>
<xforms:group ref="instance('ojoins')">
<fr:datatable>
<thead>
<tr>
<th> Select </th>
<th fr:sortable="true" fr:sorted="ascending"> Date </th>
<th fr:sortable="true" fr:sortType="number"> M(l) </th>
<th fr:sortable="true" fr:sortType="number"> Distance(k) </th>
<th fr:sortable="true" fr:sortType="number"> Depth(k) </th>
<th> Latitude </th>
<th> Longitude </th>
<th> Azimuth </th>
<th> Authority </th>
<th fr:sortable="true"> Event ID </th>
</tr>
</thead>
<tbody>
<xforms:repeat nodeset="/result/ojoin" id="ojoins-repeat">
<xxforms:variable name="ojoin" select="."/>
<xxforms:variable name="position" select="count(preceding-sibling::ojoin) + 1"/>
<tr>
<td>
<xforms:select1 ref="instance('pack')/pack/evid" appearance="full">
<xforms:item>
<xforms:value ref="$ojoin/evid"/>
<xforms:label/>
</xforms:item>
<xforms:action ev:event="xforms-select">
<xforms:setvalue ref="instance('pack')/pack/ml" value="instance('ojoins')/ojoin[$position]/ml"/>
<xforms:setvalue ref="instance('pack-form')/dirtywj" value="true()"/>
<xforms:setvalue ref="instance('pack-form')/dirtytr" value="true()"/>
</xforms:action>
</xforms:select1>
</td>
<td> <xforms:output ref="time" xxforms:format="format-dateTime(.,'[Y]-[M00]-[D00] &nbsp; [h00]:[m00]:[s00]')"/> </td>
<td> <xforms:output ref="ml" xxforms:format="format-number(.,'##.00')"/> </td>
<td style="text-align: right;"> <xforms:output ref="distance" xxforms:format="format-number(.,'####.0')"/> </td>
<td style="text-align: right;"> <xforms:output ref="depth" xxforms:format="format-number(.,'###.0')"/> </td>
<td> <xforms:output ref="lat" xxforms:format="format-number(.,'####.000')"/> </td>
<td> <xforms:output ref="lon" xxforms:format="format-number(., '####.000')"/> </td>
<td> <xforms:output ref="azimuth"/> </td>
<td> <xforms:output ref="auth"/> </td>
<td style="text-align: right;"> <xforms:output ref="evid"/> </td>
</tr>
</xforms:repeat>
</tbody>
</fr:datatable>
</xforms:group>
<fr:xforms-inspector/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment