我正在使用带有过滤器的primefaces
数据表。在过滤器中,我有两个下拉选择框。我想先选择后修改第二个下拉框。
这是我的代码:
<p:dataTable id="stockTable1" widgetVar="stockTable" var="stock" value="#{stockBean.stockList}" filteredValue="#{stockBean.filteredStocks}" paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,20, 50">
<p:column headerText="Product Id" sortBy="#{stock.name}" filterBy="#{stock.name}">
<h:outputText value="#{stock.name}" />
</p:column>
<p:column headerText="Category" sortBy="#{stock.categoryId}" filterBy="#{stock.categoryId}" filterMatchMode="exact">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('stockTable').filter()" value="#{stockBean.selectedCategory}">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{stockBean.categoryNames}" />
</p:selectOneMenu>
</f:facet>
<h:outputText value="#{stock.categoryId}" />
</p:column>
<p:column headerText="Sub Category" sortBy="#{stock.subCategoryId}" filterBy="#{stock.subCategoryId}" filterMatchMode="exact" >
<f:facet name="filter">
<p:selectOneMenu onchange="PF('stockTable').filter()" immediate="true" id="subChange">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{stockBean.subcategoryNames}" />
</p:selectOneMenu>
</f:facet>
<h:outputText id="stockDescription" value="#{stock.subCategoryId}" />
</p:column>
<p:column headerText="Last Updated" sortBy="#{stock.updatedTS}" >
<h:outputText value="#{stock.updatedTS}" >
<f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss"/>
</h:outputText>
</p:column>
</p:dataTable>
我想在选择类别后修改子类别下拉框。
答案 0 :(得分:1)
您可以将WHERE
个事件附加到第一个p:ajax
:
p:selectOneMenu
例如,您可以在新方法<p:selectOneMenu onchange="PF('stockTable').filter()"
value="#{stockBean.selectedCategory}">
<!-- ... -->
<p:ajax event="change"
process="stockTable1"
update="stockTable1"
partialSubmit="true"
listener="#{stockBean.changeSubcategoryNames}"/>
内调整subChange
的值。