多项选择的怪异行为 [英] Multiple selection strange behaviour
问题描述
我的数据表定义如下:
<p:dataTable id="sifarnikTable" rowIndexVar="rowIndex"
value="#{attrsBean.listOfDataBeans}" editable="true"
selectionMode="multiple" selection="#{attrsBean.selektovani}"
widgetVar="datatableWidget" var="row" rowKey="#{row.primaryKey}"
paginator="true" paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
currentPageReportTemplate="{startRecord} - {endRecord} / {totalRecords}"
emptyMessage="#{messages['datatable.emptymessage']}" rows="15"
sortMode="multiple" paginatorAlwaysVisible="false" styleClass="newStyle"
filteredValue="#{attrsBean.filteredDatatableList}">
<p:ajax event="rowSelect" />
<p:ajax event="rowUnselect" />
<p:ajax event="rowEdit" listener="#{attrsBean.onEdit}"
update=":aswdatatable:form:messages, :aswdatatable:form:sifarnikTable, :aswdatatable:form:noviBtn" />
<p:ajax event="rowEditCancel" listener="#{attrsBean.onCancel}"
update=":aswdatatable:form:messages" />
<p:columns id="columns" var="column" value="#{attrsBean.columns}"
style="#{column.css}" width="#{column.width}"
sortBy="#{row[column.property]}"
filterStyle="#{attrsBean.columnCSS}"
filterBy="#{attrsBean.showFilter==false ? null : row[column.property]}">
<f:facet name="header">
<h:outputText value="#{column.header}" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{row[column.property]}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{row[column.property]}" style="width:96%"></p:inputText>
</f:facet>
</p:cellEditor>
</p:columns>
<p:column style="width:6px" exportable="false" >
<p:rowEditor />
</p:column>
<p:column style="width:6px" exportable="false">
<div
onclick="datatableWidget.unselectAllRows();datatableWidget.selectRow(#{rowIndex}, false);">
<h:panelGroup layout="block">
<p:cellEditor>
<f:facet name="output">
<p:commandLink id="deleteBtn"
onclick="datatableWidget.unselectAllRows();datatableWidget.selectRow(#{rowIndex}, false);brisanjeWidget.show()"
process="@this"
update=":aswdatatable:form:brisanjeDisplay, :aswdatatable:form:sifarnikTable"
styleClass="ui-icon ui-icon-trash">
<f:setPropertyActionListener
target="#{attrsBean.modelForDelete}" value="#{row}" />
</p:commandLink>
</f:facet>
<f:facet name="input">
<h:outputText value="" />
</f:facet>
</p:cellEditor>
</h:panelGroup>
</div>
</p:column>
</p:dataTable>
一个问题是,当我选择项目时,行为有些奇怪.有时,当我单击特定行时,它不会选择它,有时会选择它,有时,我需要单击多次以选择一行.有人可以帮忙吗?也许我看不到任何东西.
A problem is when I select items behaviour is a little strange. Sometimes when I click on specific row it won't select it and sometimes it does and sometimes I need to click more than once to select a row. Can anyone help? Maybe I don't see something.
相关的支持bean代码是:
Relevant backing bean code is:
@PostConstruct
public void init() {
...
selektovani = new ArrayList<BasicModel>();
...
}
推荐答案
我唯一能找到的答案是重写datatable.js中的onRowClick函数.更改在if ($(event.target).is("td,span:not(.ui-c)")) {
行中,我刚刚更改为if ($(event.target).is("td,span:not(.ui-c),.ui-cell-editor-output")) {
,现在可以正常工作了.我知道这不是好方法.
The only answer I could find is to override onRowClick function from datatable.js. The change is in line if ($(event.target).is("td,span:not(.ui-c)")) {
, I've just changed to if ($(event.target).is("td,span:not(.ui-c),.ui-cell-editor-output")) {
and now it works. I know that this is not good way.
这篇关于多项选择的怪异行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!