Skip to content

Instantly share code, notes, and snippets.

@hgoetzger
Created March 6, 2014 11:14
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 hgoetzger/9387531 to your computer and use it in GitHub Desktop.
Save hgoetzger/9387531 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<xh:html
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms">
<!-- example of datatable for orbeon-CE 4.4 with external paging -->
<xh:head>
<xf:model>
<xf:instance id="items">
<items>
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
<item>20</item>
<item>21</item>
<item>22</item>
<item>23</item>
<item>24</item>
<item>25</item>
<item>26</item>
<item>27</item>
<item>28</item>
<item>29</item>
</items>
</xf:instance>
<xf:instance id="pageControl">
<params xmlns="">
<rowsPerPage/>
<page/>
<from/>
<to/>
<numberOfRows/>
<nbPages/>
</params>
</xf:instance>
<xf:var
name="page"
value="instance('pageControl')"/>
<xf:bind
name="pagePage"
id="pagePage-bind"
nodeset="$page/page"
xxf:default="1"/>
<xf:bind
name="rowsPerPage"
id="rowsPerPage-bind"
nodeset="$page/rowsPerPage"
xxf:default="if(xxf:get-request-parameter('rpp')) then xxf:get-request-parameter('rpp') else '20'"/>
<xf:bind
name="numberOfRows"
id="numberOfRows-bind"
ref="$page/numberOfRows"
type="xf:integer"
calculate="count(instance('items')/item)"/>
<xf:bind
id="nbPages-bind"
nodeset="$page/nbPages"
type="xf:integer"
calculate="ceiling(number($numberOfRows) div number($rowsPerPage))"/>
<xf:bind
name="from"
id="from-bind"
nodeset="$page/from"
type="xf:integer"
calculate="($page/page - 1) * $rowsPerPage"/>
<xf:bind
name="to"
id="to-bind"
nodeset="$page/to"
type="xf:integer"
calculate="$page/page * $rowsPerPage"/>
</xf:model>
</xh:head>
<xh:body>
<xf:output ref="$page/numberOfRows">
<xf:label>
No of items:
</xf:label>
</xf:output>
<fr:datatable
paginated="true"
pagination-mode="external"
page="$page/page"
nbPages="$page/nbPages"
maxNbPagesToDisplay="7">
<xf:setvalue
ev:event="fr-goto-page"
ref="$page/page"
value="event('fr-new-page')"/>
<xh:thead>
<xh:tr>
<xh:th>
item
</xh:th>
</xh:tr>
</xh:thead>
<xh:tbody>
<xh:tr repeat-nodeset="item[position() &gt; $page/from and position() &lt;= $page/to]">
<xh:td>
<xf:output
type="text"
ref="."/>
</xh:td>
</xh:tr>
</xh:tbody>
</fr:datatable>
<!-- <fr:xforms-inspector xmlns:fr="http://orbeon.org/oxf/xml/form-runner"/> -->
</xh:body>
</xh:html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment