Вопрос

I want to do some opertaions in the row of my JSF datatable, and for that i need and id of row. But when i see html generated through firebug. I notice that id is getting generated only for JSF components not of tr and td. Is there someway by which i can define the id of row(tr) Here is my code

<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 . I can just hide/show that row using jquery. So can i do that ?

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. E.g. for sports student class is sport and ordinary for others. And then you can hide/show all rows, which contains elements with ordinary class.
  2. Filter students on server. Send ajax request which will rerender your table, leaving only sports student. You can do this pretty simple if you use some JSF library with ajax support, e.g. primefaces.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top