如何在jsf或primefaces dataTable中进行多项选择? [英] How to do multiple selection in jsf or primefaces dataTable?

查看:70
本文介绍了如何在jsf或primefaces dataTable中进行多项选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试构建一个简单的网格,该网格具有一个由复选框组成的删除列,就像电子邮件中的常用列一样.

I want to try out building a simple grid that has a delete column, consisting of checkboxes, just like the usual one in email.

然后,用户可以勾选复选框,然后按Delete键,我可以获取所有选中的记录,并一一删除.

User can then tick the checkboxes, and press delete, and i can get all the checked records, and delete them one by one.

我正试图找到一种方法来实现这一目标,但到目前为止,我仍然对此表示怀疑.

Im trying to find a way to achieve this, but so far im still in doubt.

这些是我要记住的,每个都有自己的实现问题,哈哈:

These are what i have in mind, each with it's own implementation question, haha :

  1. 如何获取选中的行索引?对每个复选框的每个切换都使用actionlistener? (但是如何将点击的索引传递给actionlistener?)
  2. 或者是否有一种方法可以获取所有网格模型,并循环数据以找出要检查的网格,就像swing一样? (但是如何在jsf bean中获得网格模型?)
  3. 或者我应该将它们绑定到仅包含复选框列数据的简单列表? (但是我如何使用索引将每个复选框绑定到列表?)

我目前正在使用素数,但我认为JSF解决方案也可以应用于素数数据表.

Im currently using primefaces, but i think the JSF solution can also be applied to primefaces datatable.

请分享您对此的想法!

谢谢!

推荐答案

不是此Primefaces展示柜中的示例您到底在寻找什么?

Isn't this example from Primefaces showcase exactly what you are looking for?

看起来它只是这样向p:dataTable添加一列:

It looks that it is simply adding a column to the p:dataTable this way:

<p:dataTable var="item" value="#{yourBean.allElements}"  
             selection="#{yourBean.selectedElements}">
    <p:column selectionMode="multiple" />
    ... other columns
</p:dataTable>

这篇关于如何在jsf或primefaces dataTable中进行多项选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆