【问题标题】:How move to a another page in paginatortemplate that contains selected row如何移动到包含选定行的分页器模板中的另一个页面
【发布时间】:2015-03-21 03:07:26
【问题描述】:

我有一个 primefaces 数据表,它带有一个处于选择模式的分页器模板。例如,如果我在第一页,并且我在我的 bean 中选择了 paginatortemplate 数据表第 4 页中的记录,我如何以编程方式移动到第 4 页以查看所选行?

xhtml:

<p:dataTable id="tablaVista" 
   var="u"
   value="#{mtoArticulosBean.listaGeneral}"
   emptyMessage="#{msgs.NoHayRegistros}"
   paginator="true" rows="12"  
   paginatorTemplate="{CurrentPageReport}  {FirstPageLink}   PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} "  
   selection="#{mtoArticulosBean.registroSel}"
   selectionMode="single" 
   rowKey="#{u.codArticulo}">
   .....
</p:datatable

mtoArticulosBean:

....

setRegistroSel(getListaGeneral().get(42));

....

尽管所选记录在第 4 页上,但用户仍然看到第 1 页

提前致谢

【问题讨论】:

    标签: jsf-2 primefaces datatable


    【解决方案1】:

    您可以(应该)使用数据表的“first”属性。设置选择时,计算它在哪个页面上(记录数/页面大小)并在 bean 中使用。

    然后你可以在你的 xhtml 中做

    <p:datatable first="#{myBean.first}"....    
    

    (另见Primefaces: set page on datatable

    【讨论】:

    • 非常感谢。这正是我所需要的
    猜你喜欢
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-15
    相关资源
    最近更新 更多