问题描述
我有问题 p:dataTable
,并排除单列选择列。
I've got problem with p:dataTable
and excluding a column from single row selection.
我在我的dataTable中有4列。首先需要显示fileId,fileName和uploadDate。在第4列中,每行开始执行文件处理的命令按钮。
还可以导航到文件详细信息页面的行选择(对事件有ajax操作)。
现在,当我点击行上的任何地方(包括按钮),它导航到详细信息页面。
I have 4 columns in my dataTable. First 3 are needed to display fileId, fileName and uploadDate. In 4th column there is a command button for each row that start action of file processing.But also there is row selection (with ajax action on event) that navigates to file details page.Now, when I click on the anywhere on the row (including the button) it navigates me to details page.
有我现在的代码:
<h:form>
<p:dataTable id="billingFiles" value="#{billingFiles}"
var="billingFile"
rowKey="#{billingFile.billingFile.idBillingFile}"
filteredValue="#{billingService.filteredBillingFileDataModels}"
selectionMode="single" paginator="true" rows="10">
<p:ajax event="rowSelect" listener="#{billingService.selectBillingFileRow}" />
<p:column sortBy="#{billingFile.id}"
filterBy="#{billingFile.id}" id="idFile"
headerText="#{msg['billing.file.id']}"
filterMatchMode="contains">
<h:outputText value="#{billingFile.id}" />
</p:column>
<p:column sortBy="#{billingFile.uploadDate}"
filterBy="#{billingFile.uploadDate}" id="uploadDate"
headerText="#{msg['billing.file.upload_date']}"
filterMatchMode="contains">
<h:outputText value="#{billingFile.uploadDate}" />
</p:column>
<p:column sortBy="#{billingFile.fileName}"
filterBy="#{billingFile.fileName}" id="fileName"
headerText="#{msg['billing.file.file_name']}"
filterMatchMode="contains">
<h:outputText value="#{billingFile.fileName}" />
</p:column>
<p:column id="loadBillingFile">
<p:commandButton id="loadBillingFileButton"
rendered="#{billingFile.fileStatus.equals('UPLOADED')}"
value="#{msg['billing.load_billing_file']}"
action="#{billingService.loadBillingFile(billingFile.billingFile)}"
update=":form" />
</p:column>
</p:dataTable>
</h:form>
还有导航到文件详细信息页面的方法:
And there is the method that navigates to file details page:
public void selectBillingFileRow(SelectEvent event) {
BillingFileDataModel billingFileDataModel = (BillingFileDataModel) event.getObject();
if (billingFileDataModel != null) {
selectedBillingFile = billingFileDAO.findBillingFileById(billingFileDataModel.getBillingFile().getIdBillingFile());
FacesContext.getCurrentInstance().getExternalContext()
.getRequestMap().put(JsfView.EVENT_KEY, "viewBillingFile");
}
}
有没有办法排除列的按钮行选择?我只需要开始处理文件,而不用导航到其他页面。
Is there any way to exclude column with the button from row selection? I need it only to start processing the file, without navigating me to other page.
推荐答案
我发现我的问题的部分解决方案。
当 onClick
事件发生时,我阻止了 rowSelect
ajax操作执行。
I found a partial solution to my problem.I prevented rowSelect
ajax action from executing, when onClick
event occurs.
我将此行添加到 p:commandButton
:
onclick="event.stopPropagation();"
我说这部分工作,因为点击列按钮,但不是按钮本身,仍然执行 rowSelect
操作。
I said it works partially, because click on column with button, but not on the button itself, still executes rowSelect
action.
这篇关于引用:从p:dataTable中的行选择中排除列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!