简体   繁体   English

jsf 数据表的行 ID

[英]row id of jsf datatable

I want to do some opertaions in the row of my JSF datatable, and for that i need and id of row.我想在我的 JSF 数据表的行中做一些操作,为此我需要行的 ID。 But when i see html generated through firebug.但是当我看到通过萤火虫生成的 html 时。 I notice that id is getting generated only for JSF components not of tr and td.我注意到 id 仅针对 JSF 组件而不是 tr 和 td 生成。 Is there someway by which i can define the id of row(tr) Here is my code有什么办法可以定义 row(tr) 的 id 这是我的代码

<h:datatable value = "#{bean.list}" var = "row">
   <h:column> 
       #{row.name}
   </h:column>
   <h:column> 
       #{row.address}
   </h:column>
   <h:column> 
       #{row.phone no}
   </h:column>
   <h:column> 
       <h:selectBooleanCheckbox id="checkbox" value="#{row.sportsStudent}" />
   </h:column>
</h:datatable>

There is a button below my datatable which says "Show only sports student" and my list should show only sports student and caption will change to "Show all students".我的数据表下方有一个按钮,上面写着“只显示体育学生”,我的列表应该只显示体育学生,标题将更改为“显示所有学生”。 now all students should be displayed.现在应该显示所有学生。 So i was thinking if i have id of tr.所以我在想我是否有 tr 的 ID。 I can just hide/show that row using jquery. So can i do that?我可以使用 jquery 隐藏/显示该行。我可以这样做吗?

Thanks in advance.提前致谢。

Tarun Madaan塔伦马达安

You have several options.您有多种选择。 I can propose 2 of them:我可以提出其中的两个:

  1. You can add class with description to some column in datatable.您可以将 class 与描述添加到数据表中的某些列。 Eg for sports student class is sport and ordinary for others.例如,对于体育学生 class 是sport ,对于其他人来说是ordinary的。 And then you can hide/show all rows, which contains elements with ordinary class.然后你可以隐藏/显示所有行,其中包含ordinary class 的元素。
  2. Filter students on server.在服务器上过滤学生。 Send ajax request which will rerender your table, leaving only sports student.发送 ajax 请求,这将重新呈现您的表格,只留下体育学生。 You can do this pretty simple if you use some JSF library with ajax support, eg primefaces.如果您使用一些支持 ajax 的 JSF 库,例如 primefaces,您可以非常简单地做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM