1

我正在使用 PF 4.0,并且我有一个延迟加载的数据表,我正在尝试将过滤器文本框添加到“名称”列,但文本框没有出现。我错过了什么?

...
<p:dataTable var="user" value="#{userGroupBacking.users}" editable="true" id="userTable" paginator="true" rows="20"  
    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}" lazy="true"
    filteredValue="#{userGroupBacking.filteredUsers}" >

    <p:ajax event="rowEdit" listener="#{userGroupBacking.onEdit}" /> 

    <p:column headerText="User" filterBy="#{user.name}" filterMatchMode="contains">
        <h:outputText value="#{user.name}" />
    </p:column>
...

后备豆:

@ManagedBean(name="userGroupBacking")
@ViewScoped
public class UserGroupBacking {

@ManagedProperty(value="#{accessBacking}")
    private AccessBacking accessBacking;
    public void setAccessBacking(AccessBacking accessBacking) {
        this.accessBacking = accessBacking;
    }

@PostConstruct
    public void init() {
        this.ds = databaseBacking.getDs();
        if(isLoggedIn()) {
            loadData();
        }
    }

/**
     * Checks that the user is logged in
     * @return
     */
    public boolean isLoggedIn() {
        return accessBacking.isHasAccess();
    }

public LazyDataModel<User> getUsers() {
        return users;
    }
    public List<Group> getGroups() {
        return groups;
    }
    public List<Group> getSelectedGroups() {
        return selectedGroups;
    }
    public List<SelectItem> getGroupsAsSelectItems() {
        return groupsAsSelectItems;
    }
    public List<SelectItem> getUsersAsSelectItems() {
        return usersAsSelectItems;
    }
    public String getNewGroup() {
        return newGroup;
    }
    public void setNewGroup(String newGroup) {
        this.newGroup = newGroup;
    }
    public List<User> getFilteredUsers() {
        return filteredUsers;
    }
    public void setFilteredUsers(List<User> filteredUsers) {
        this.filteredUsers = filteredUsers;
    }
}
4

2 回答 2

6

我想到了。似乎在 PF 4.0 中,您需要将 filterBy 代码更改为:

<p:column headerText="User" filterBy="#{user.name}" filterMatchMode="contains">
    <h:outputText value="#{user.name}" />
</p:column>

至:

<p:column headerText="User" filterBy="name" filterMatchMode="contains">
    <h:outputText value="#{user.name}" />
</p:column>
于 2013-10-23T18:25:04.283 回答
0

我只是好奇,这是您页面中的实际代码吗?因为它应该包裹在里面<p:cellEditor>,如 primefaces 展示中所示

http://www.primefaces.org/showcase-labs/ui/datatableRowEditing.jsf

就像是

<p:column headerText="Model" style="width:30%">  
            <p:cellEditor>  
                <f:facet name="output">  
                    <h:outputText value="#{car.model}" />  
                </f:facet>  
                <f:facet name="input">  
                    <p:inputText value="#{car.model}" style="width:100%"/>  
                </f:facet>  
            </p:cellEditor>  
        </p:column> 
于 2013-10-18T20:50:35.613 回答