Custom paging Example with explicit totalcount
In this example, a custom list of the macros available in the current security zone is used. On the first page, the total number of records is retrieved and set using an if macro.
Smartsite SXML | Copy Code |
---|---|
<se:hidden> {buffer.set(list, sxml.securityzone.listassets(Macro))} <se:paging pagesize="20" /> <se:if expression="scope.paging.gettotalcount() LTE 0"> {scope.paging.settotalcount(datatable.rows.count($list))} </se:if> <se:format inputdata="{buffer.get(list)}" skiprows="{scope.paging.skip()}" maxrows="{scope.paging.size()}"> <se:rowformat> <li>{this.field(1)}</li> </se:rowformat> <se:resultformat> <ul>{this.result()}</ul> </se:resultformat> </se:format> </se:hidden> <span class="navbar"> {scope.paging.goto(First)} {scope.paging.goto(Previous)} {buffer.set(range, 6)} {buffer.set(start, math.max(scope.paging.current()-($range/2),1))} <se:for from="{buffer.get(start)}" to="{math.min($start+$range, scope.paging.count())}"> {scope.paging.goto(this.index())} </se:for> {scope.paging.goto(Next)} {scope.paging.goto(Last)} </span> |
Example Result | Copy Code |
---|---|
<span class="navbar"> |< < 1 <a href="http://doc6/test.net?id=29800&paging_page=2&paging_count=97">2</a> <a href="http://doc6/test.net?id=29800&paging_page=3&paging_count=97">3</a> <a href="http://doc6/test.net?id=29800&paging_page=4&paging_count=97">4</a> <a href="http://doc6/test.net?id=29800&paging_page=5&paging_count=97">5</a> <a href="http://doc6/test.net?id=29800&paging_page=2&paging_count=97">></a> <a href="http://doc6/test.net?id=29800&paging_page=5&paging_count=97">>|</a> </span> |