我正在尝试创建默认的过滤值数据表。页面加载时如何为过滤器/数据表设置默认值?
试图在中添加filterValue =“ BMW”>
<p:column headerText="Car Type" sortBy="#{car}" filterBy="#{car}" filterValue="BMW" id="carTypeColumn"> <h:outputText id="car" value="#{carResultsRow.car.type}" /> </p:column>
<p:dataTable id="carResults" value="#{carMB.car}" var="carResultsRow" rows="20" paginator="true" widgetVar="carResultsVar" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" style="margin-bottom:20px" rowIndexVar="rowIndex" lazy="true" sortOrder="DESCENDING" currentPageReportTemplate="(Displaying {startRecord} - {endRecord} of {totalRecords})" rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'highlight1' : 'highlight2'}" emptyMessage="No results found for search." reflow="true"> <p:column headerText="Car Type" sortBy="#{car}" filterBy="#{car}" id="carTypeColumn"> <h:outputText id="car" value="#{carResultsRow.car.type}" /> </p:column>
以下数据表产生结果-
实际结果
ID Year Type Color Status Price adff7ca0 1974 BMW Blue Sale $14,160.00 50f83d04 1998 Renault Silver Sale $43,645.00 27b7be8d 1995 Merc Red Sold $80,627.00 b35c4322 2006 BMW Orange Sold $16,051.00 7888e692 1997 Fiat Red Sale $4,508.00 adbf1199 2004 Audi Brown Sale $37,511.00 8eb3e5a9 1985 Honda Black Sold $46,729.00 fed0821c 1990 BMW Red Sale $88,185.00 85d2282f 1967 Honda Orange Sold $33,674.00 bc34ed49 1972 BMW Blue Sale $81,567.00
预期结果
adff7ca0 1974 BMW Blue Sale $14,160.00 b35c4322 2006 BMW Orange Sold $16,051.00 fed0821c 1990 BMW Red Sale $88,185.00 bc34ed49 1972 BMW Blue Sale $81,567.00
如何在页面加载时为过滤器/数据表设置默认值?
发布解决方案的结果
filterBy="#{carMB.filterBy}" filterBy = singletonList(new FilterState(
ID Year Type Color Status Price
BMW -------------- Appeared in the filter header
dff7ca0 1974 BMW Blue Sale $14,160
f83d04 1998 Renault Silver Sale $43,640
7be8d 1995 Merc Red Sold $80,627
5c4322 2006 BMW Orange Sold $16,051
88e692 1997 Fiat Red Sale $4,508
bf1199 2004 Audi Brown Sale $37,511
3e5a9 1985 Honda Black Sold $46,729
0821c 1990 BMW Red Sale $88,185
2282f 1967 Honda Orange Sold $33,674
4ed49 1972 BMW Blue Sale $81,567
我正在尝试创建默认的过滤值数据表。页面加载时如何为过滤器/数据表设置默认值?尝试在