DataTable: filterBy is not called after AJAX update
See original GitHub issueDescription DataTable is not calling the filterBy properties after ajax Update. The code was working in PF10 Community.
Environment:
- PF Version: 11.0.1
- PF Theme: Poseidon 4.1.0
- JSF 2.3 GlassFish 5.1
- Firefox and Chrome
Expected behavior function stated in p:dataTable filterBy is called by respecting the value from variable “showDeleted”. When the page is called the value for “showDeleted” is false. If the user set the value from Checkbox to true, the datatable should update and call the filterby Property again showDeleted is now true and the data should switch the fillter. In PF10 it works perfectly. In PF11 the function “objectController.getDefaultFilterMeta” is not called.
Example XHTML
<h:form id="frmInternalContact">
<p:remoteCommand name="refresh" update="dtaInternalContact" complete="PF('widInternalContact').filter()" />
<p:selectBooleanCheckbox id="sbcShowDeleted" value="#{iNCOController.showDeleted}" onchange="refresh()">
<p:ajax process="@this" />
</p:selectBooleanCheckbox>
<p:dataTable
id="dtaInternalContact"
value="#{iNCOController.items}"
var="row"
widgetVar="widInternalContact"
selectionMode="multiple"
liveScroll="false"
scrollable="true"
scrollHeight="630"
selection="#{iNCOController.selectedItems}"
filteredValue="#{iNCOController.filteredItems}"
filterBy="#{iNCOController.showDeleted ? objectController.getDefaultFilterMeta('defaultDeleted') :
objectController.getDefaultFilterMeta('dtaInternalContact')}"
sortBy="#{objectController.getDefaultSortMeta('dtaInternalContact')}"
sortMode="multiple"
allowUnsorting="true"
paginator="true"
paginatorPosition="bottom"
paginatorAlwaysVisible="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
currentPageReportTemplate="{totalRecords} record(s)"
rows="100"
rowsPerPageTemplate="100,200,300,400,500"
rowKey="#{row.internalContactPk}"
resizableColumns="true"
liveResize="true"
draggableColumns="true"
reflow="true"
showGridlines="true"
rowStyleClass="#{row.deleted ? 'row_deleted' : !row.activeFlag ? 'row_inactive' : null}"
styleClass="ui-datatable-striped ui-datatable-sm">
<p:columns value="#{iNCOController.mainTableColumns}"
var="column"
headerText="#{column.header}"
field="#{column.property}"
styleClass="#{column.adjust}"
style="width:#{column.width}"
visible="#{column.visible}"
filterable="#{column.filterable}"
filterMatchMode="#{column.type eq 'boolean' ? 'equals' : 'contains'}"
sortable="#{column.sortable}">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('widInternalContact').filter()" rendered="#{column.type eq 'boolean'}">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="True" itemValue="true" />
<f:selectItem itemLabel="False" itemValue="false" />
</p:selectOneMenu>
<p:selectOneMenu onchange="PF('widInternalContact').filter()" rendered="#{column.type eq 'state'}">
<f:converter converterId="javax.faces.Boolean" />
<f:selectItem itemLabel="All" itemValue="" />
<f:selectItem itemLabel="Contact" itemValue="false" />
<f:selectItem itemLabel="List" itemValue="true" />
</p:selectOneMenu>
</f:facet>
<h:outputText rendered="#{column.type eq 'string'}" value="#{row[column.property]}" />
<h:outputText rendered="#{column.type eq 'datetime'}" value="#{row[column.property]}">
<f:convertDateTime locale="#{parameterSessionController.localeCode}" type="localDateTime" dateStyle="medium"
timeStyle="short"/>
</h:outputText>
<p:outputLabel rendered="#{column.type eq 'boolean' and row[column.property]}">
<i class="pi pi-check-circle" />
</p:outputLabel>
<p:outputLabel rendered="#{column.type eq 'state' and row[column.property] eq true}">
<i class="pi pi-list" />
</p:outputLabel>
<p:outputLabel rendered="#{column.type eq 'state' and row[column.property] eq false}">
<i class="pi pi-user" />
</p:outputLabel>
</p:columns>
</p:dataTable>
</h:form>
Example Bean
@Named
@SessionScoped
public class ObjectController implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String,List<SortMeta>> sortMap = new HashMap<String,List<SortMeta>>();
private Map<String,List<FilterMeta>> filterMap = new HashMap<String,List<FilterMeta>>();
/* CONTROLLER CREATION DEFINITIONS */
public ObjectController () {
createDefaultSortMeta();
createDefaultFilterMeta();
}
public List<SortMeta> getDefaultSortMeta(String table) {
return sortMap.get(table);
}
public List<FilterMeta> getDefaultFilterMeta(String table) {
return filterMap.get(table);
}
private void createDefaultSortMeta() {
sm = new ArrayList<SortMeta>();
sm.add(SortMeta.builder().field("distributionList").order(SortOrder.ASCENDING).priority(1).build());
sortMap.put("dtaInternalContact", sm);
}
private void createDefaultFilterMeta() {
List<FilterMeta> fm = new ArrayList<FilterMeta>();
fm.add(FilterMeta.builder().field("deleted").filterValue(true).matchMode(MatchMode.EQUALS).build());
filterMap.put("defaultDeletedwoActive", fm);
fm = new ArrayList<FilterMeta>();
fm.add(FilterMeta.builder().field("activeFlag").filterValue(true).matchMode(MatchMode.EQUALS).build());
fm.add(FilterMeta.builder().field("deleted").filterValue(false).matchMode(MatchMode.EQUALS).build());
filterMap.put("dtaInternalContact", fm);
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (12 by maintainers)
Top Results From Across the Web
Ajax update doesn't work, when using filter on p:dataTable
The datable will be updated after the user's operation is completed using ajax. It updates the table directly and works well, if I...
Read more >After ajax call filter and sort is working but data is not updating.
Hello, I am using datatable in my application.I am facing an issue like after ajax call filter and sort is working but data...
Read more >Datatable update after filtering not working - PrimeFaces forum
I have a problem. I have data table with 4 columns. When I filter by some fileds, and clear filtered word, after click...
Read more >primefaces - issue #4840 - Google Code
I have a problem with p:galleria component in case I want to update it with an ajax call. My code below is working...
Read more >ASP.NET Core Razor Pages: How to implement AJAX requests
Last Updated: July 31, 2020 | Created: April 2, 2018. ASP.NET Core 2.0 introduced a new way to build a web site, called...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@danteCarvalho please dont use this issue to talk about your issue, its quite different. Better see: https://github.com/primefaces/primefaces/issues/8159
current behavior is fine