Conditionally display row using JSF Datatable

后端 未结 6 1297
無奈伤痛
無奈伤痛 2021-02-19 07:16

I have some JSF code that currently works (as shown below), and I need to modify it to conditionally suppress the display of certain rows of the table. I know how to conditional

6条回答
  •  一整个雨季
    2021-02-19 08:05

    Rows correspond to data objects in the collection of your table. If you don't want the row, don't put the object in the collection.

    Alternatively, you can use the rowClasses parameter for dataTable.

    Bean code:

    public String getRowClasses() {
        StringBuilder sb = new StringBuilder();
        for (Data data : myData) {
            sb.append(data.hide ? 'hide,' : 'show,');
        }
        return sb.toString();
    }
    

    CSS:

    tr.hide {display:none;}
    

提交回复
热议问题