Primefaces Datatable checkbox affecting ability to copy and paste

I have a primefaces table with a multiple checkbox column and the way it works currently is that any click on any part of a row selects the row

How can I change it so that the row is selected only by clicking within the checkbox?

I wan this change because it will allow data in other columns to be copied after highlighting.

The issue right now is that whenever I try to highlight data in a cell, the row I clicked in gets selected and I am unable to highlight the data(and therefore unable to copy the data).

Below is my primefaces table:

<p:dataTable id="abc" value="#{myBean.getRows()}" var="row" rendered="#{!myBean.getRows().isEmpty()}" lazy="false" paginator="true" paginatorAlwaysVisible="false" rows="20" selection="#{myBean.selectedRows}" rowKey="#{uiRow.id}">
            <p:column selectionMode="multiple" style="float:center"/> <!--checkbox column-->
            <p:column id="data_id" headerText="#{bundle.id}" sortBy="#{uiRow.id}" filterBy="#{uiRow.id}" filterMatchMode="contains" filterStyle="width: 60px">
                <h:outputText value="#{uiRow.id} "/>
            </p:column>
            <p:column id="data_state" headerText="#{bundle.data_state}" sortBy="#{uiRow.stateRow}" filterBy="#{uiRow.stateRow}" filterMatchMode="contains" filterStyle="width: 60px">
                <h:outputText value="#{uiRow.stateRow} "/>
            </p:column>
            <p:column>
            ....

You could make your own selection checkbox and add it as a column to the datatable.

<p:column id="select">
    <p:selectBooleanCheckbox value="#{row.checked}"/>
</p:column>

And then you could iterate over all the checked objects in your backing bean and do whatever you want with them...

链接地址: http://www.djcxy.com/p/68550.html

上一篇: 使用动态sql查询使用primefaces数据导出器

下一篇: Primefaces Datatable复选框影响复制和粘贴的能力