我试图将selectOneButton菜单放置在我的数据表之外,并使其强制过滤器(就像该过滤器是facet头一样,如演示)
本质上:
selectOneButton正确传递值
<script>
function test(val){
console.log(val);
$("#allUsersForm\\:myTable\\:statusColumn\\:filter").val(val);
$("#allUsersForm\\:myTable\\:statusColumn\\:filter").trigger('keyup');
}
</script>
<h:form>
<p:selectOneButton widgetVar="statusSelectWidget"
onchange="test(PF('statusSelectWidget').inputs.filter(':checked').val());">
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="A" itemValue="true" />
<f:selectItem itemLabel="I" itemValue="false" />
</p:selectOneButton>
</h:form>
<h:form id="allUsersForm">
<p:dataTable
id="myTable"
var="user"
widgetVar="userListWidget"
filteredValue="#{myController.filteredUsers}"
value="#{myController.allUsers}">
<p:column id="statusColumn" style="width:10%;" headerText="Status" sortBy="#{user.isActive}"
filterBy="#{user.isActive}" filterMatchMode="equals"
filterStyle="display:none;">
<f:facet name="filter">
<p:selectOneButton style="display:none;" widgetVar="inTableStatusWidget" onchange="PF('userListWidget').filter()">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="A" itemValue="true" />
<f:selectItem itemLabel="I" itemValue="false" />
</p:selectOneButton>
</f:facet>
<h:outputText value="#{user.isActive ? 'Active' : 'Inactive'}" />
</p:column>
</p:dataTable>
</h:form>
有什么想法吗?我想避免必须自己进行过滤或在必要时回拨支持bean。