DataTable Paging Example with page range
In this example, we create a cached datatable that we will use for paging.
The skiprows and maxrows parameters of the format macro are set using the state of the paging macro.
A range of pages to jump to is shown to the user (new in 1.2).
| Smartsite SXML |
|
|---|---|
<se:cache save="key = this.getcachekey()" resulttype="none" >
<se:sqlquery
sql="select nr, title, description from {channel.view()} order by title"
save="a"
resulttype="datatable"
/>
<se:xlinks inputdata="a" resulttype="datatable" />
</se:cache>
<se:paging
id="paging"
inputdata="key"
pagesize="20"
/>
<se:format inputdata="key"
maxrows="{page.paging.size()}"
skiprows="{page.paging.skip()}" >
<se:rowformat>
<li><a href="{this.location()}">{this.field(title)}</a></li>
</se:rowformat>
<se:resultformat>
<ul>{this.result()}</ul>
</se:resultformat>
</se:format>
<span class="navbar">
{page.paging.goto(First)}
{page.paging.goto(Previous)}
{buffer.set(range, 6, rem="Range of pages to jump to")}
{buffer.set(start, math.max(page.paging.current()-($range/2),1))}
<se:for from="{buffer.get(start)}" to="{math.min($start+$range, page.paging.count())}">
{page.paging.goto(this.index())}
</se:for>
{page.paging.goto(Next)}
{page.paging.goto(Last)}
</span>
|
|