【问题标题】:In Primefaces, adding a row to a table with filtering在 Primefaces 中,通过过滤向表中添加一行
【发布时间】:2014-06-02 08:08:33
【问题描述】:

我正在使用带有过滤功能的数据表。这是表声明:

<p:dataTable id="#{tblId}" var="p" editable="true" editMode="cell"
resizableColumns="true" rowIndexVar="rowIndex" selectionMode="multiple"
rowKey="#{p.id}" selection="#{ppselection}"
emptyMessage="No Params in table" value="#{tblValue}" scrollable="true"
style="height:100%" sortMode="multiple" styleClass="#{styleClass}"
filteredValue="#{filteredParams}">

向表中添加新行时,我希望它已经根据当前过滤器显示。即如果过滤器是“aa”并且行名称是“aabbcc”,那么我希望它显示,但如果行名称是“bbcc”,那么我不希望它显示。现在,我想出的只是决定是否要手动将其添加到过滤参数列表中。
这是表中某一列的示例,尽管所有列都是可过滤的:

    <p:column width="15%" id="ParameterColumn"  headerText="Parameter" sortBy="#{p.name}"
    filterBy="#{p.name}" filterMatchMode="contains">
    <p:cellEditor id="Parameter">
        <f:facet name="output">
            <h:outputText id="param_name" value="#{p.name}" />
        </f:facet>
        <f:facet name="input">
            <p:inputText id="nameInput" value="#{p.name}" style="width:99%"
                validator="#{p.validateParamName}">
                <p:ajax event="change"
                    update=":main_tabs:paramForm:ParamTbl, :main_tabs:paramForm:SplitedParamTbl" />
            </p:inputText>
            <p:messages for="nameInput" display="tooltip" />
        </f:facet>
    </p:cellEditor>
</p:column>

谢谢!!

【问题讨论】:

    标签: primefaces filter datatable


    【解决方案1】:

    您可以在添加新行的 ajax/button 的 oncomplete 方法中触发过滤:

    oncomplete='tableWidgetVar.filter();'
    

    【讨论】:

      猜你喜欢
      • 2015-07-15
      • 2021-10-24
      • 2020-11-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-01
      • 1970-01-01
      相关资源
      最近更新 更多