如何在ZK中创建自定义分页 [英] How to create custom pagination in ZK
问题描述
我找不到有关zk中自定义分页的任何教程. ZK提供了它的默认分页功能,还不错,但是我的客户需要不同的分页样式.因此,如何在ZK中创建自定义分页.有什么帮助吗?
I could not find any tutorial regarding custom pagination in zk. ZK provides it's default pagination and it's quite good but my customer needs different pagination style. So, how can I create custom pagination in ZK. Any help please ?
我有一个这样的列表框:
I have a listbox like this :
<listbox id="bidLbx" mold="paging">
<listitem>
...
</listitem>
</listbox>
它显示ZK的默认分页,例如:1 2 3 4 5 Next Last
,但没有用于选择每页行号的选项.因此,我需要自己的按钮"和每页"下拉选项.
It displays ZK's default pagination like: 1 2 3 4 5 Next Last
but with out option to select per page row number. So, I need my own Buttons and per page dropdown option.
推荐答案
您必须根据需要编写代码来控制分页按钮,即 First
Previous
1
2
4
5
Next
Last
You have to write the codes to control the pagination buttons as we require, i.e. First
Previous
1
2
3
4
5
Next
Last
.
我们仅引用该ID(即bidLbx
)并进行编码.我们需要获取某些值,并使用这些值来控制按钮.
We just take reference of that id i.e. bidLbx
and do coding. We need to get certain values and use those values to control the buttons.
这给出了当前页面编号:bidLbx.getPaginal().getActivePage();
This gives the current page no: bidLbx.getPaginal().getActivePage();
这给出了总行数:bidLbx.getPaginal().getTotalSize();
这将设置页面大小(即每页行数):bidLbx.getPaginal().setPageSize();
This sets the Page Size (i.e. no. of rows per page): bidLbx.getPaginal().setPageSize();
这给出了编号.页数:bidLbx.getPaginal().getPageCount();
This gives the no. of pages: bidLbx.getPaginal().getPageCount();
并且不要忘记禁用默认分页.
and don't forget to disable the default paging.
<listbox id="bidLbx" mold="paging">
...
<zscript>
<![CDATA[
bidLbx.getPagingChild().setVisible(false);
]]>
</zscript>
</listbox>
第一个按钮示例:
<button id="first" label="First" style="margin:10px; padding:5px;">
<attribute name="onClick">
<![CDATA[
bidLbx.getPaginal().setActivePage(0);
]]>
</attribute>
</button>
下拉每页组合框:
<combobox id="pageSize" value="20" style="width:50px;" readonly="true">
<comboitem label="5"></comboitem>
<comboitem label="10"></comboitem>
<attribute name="onCreate">
<![CDATA[
String ps = pageSize.getValue();
int pSize = Integer.parseInt(ps);
bidLbx.getPaginal().setPageSize(pSize);
]]>
</attribute>
<attribute name="onChange">
<![CDATA[
String ps = pageSize.getValue();
int pSize = Integer.parseInt(ps);
bidLbx.getPaginal().setPageSize(pSize);
]]>
</attribute>
</combobox>
如果您仍有问题,请发表评论.
If you have still problem do comment.
这篇关于如何在ZK中创建自定义分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!