小区选择数据表PRIMEFACES? [英] Cell Selection DataTable PRIMEFACES?
问题描述
我有一张桌子,我想单击一个单元格并显示一个对话框 但是只有我有rowSelect event,有可能做到这一点吗?...
i have a table and i wanna click a cell and show me a dialog but only i have rowSelect event , it is possible to do that?...
所以在这种情况下,我单击一行,然后在对话框中显示对象值,但是我想单击一个块以显示一个对话框
so in this case i click in a row and then show me the object values in a dialog, but i wanna click a block to show me a dialog
<h:form id="frm1">
<p:growl id="growl" showDetail="true"/>
<p:commandButton value="List" actionListener="#{tableBean.listCars()}" update="dtCar"/>
<p:dataTable id="dtCar" var="car" value="#{tableBean.carModel}"
selectionMode="single" >
<p:ajax event="rowSelect" listener="#{tableBean.readModel}"
update=":frm1:display :frm1:growl" oncomplete="carDialog.show()" />
<p:column id="model">
<f:facet name="header">
Model
</f:facet>
<h:outputText value="#{car.model}" />
</p:column>
<p:column id="year">
<f:facet name="header">
Year
</f:facet>
<h:outputText value="#{car.year}" />
</p:column>
<p:column id="manufacturer">
<f:facet name="header">
Manufacturer
</f:facet>
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column id="color">
<f:facet name="header">
Color
</f:facet>
<h:outputText value="#{car.color}" />
</p:column>
<p:column>
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":frm1:display" oncomplete="carDialog.show()" actionListener="#{tableBean.leer(car)}"/>
</p:column>
</p:dataTable>
<p:dialog id="dialog" header="Car Detail" widgetVar="carDialog" resizable="false"
showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Model:" />
<h:outputText value="#{tableBean.selectedCar.model}" />
<h:outputText value="Year:" />
<h:outputText value="#{tableBean.selectedCar.year}" />
<h:outputText value="Manufacturer:" />
<h:outputText value="#{tableBean.selectedCar.manufacturer}" />
<h:outputText value="Color:" />
<h:outputText value="#{tableBean.selectedCar.color}" />
</h:panelGrid>
</p:dialog>
</h:form>
推荐答案
Primefaces不为单元格选择提供库存支持.你需要即兴创作.
Primefaces doesn't provide stock support for cell selection. You need to improvise.
-
将所需单元格包裹在面板组件中
Wrap the desired cells in a panel component
<p:column id="model">
<f:facet name="header">
Model
</f:facet>
<h:panelGrid>
<h:outputText value="#{car.model}" />
</h:panelGrid>
</p:column>
向panelGrid添加一个onclick
属性,该属性将触发菜单
Add an onclick
attribute to the panelGrid that will trigger the menu
<p:column id="model">
<f:facet name="header">
Model
</f:facet>
<h:panelGrid onclick="dialog.show()">
<h:outputText value="#{car.model}" />
</h:panelGrid>
</p:column>
dialog
指的是与widgetVar="dialog"
在同一页面上的对话框.您可以对所有感兴趣的单元格重复此操作
Where dialog
refers to a dialog box that you would have on the same page with widgetVar="dialog"
. You can repeat this for all the cells you're interested in
这篇关于小区选择数据表PRIMEFACES?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!