question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DataTable: when it is updated, the filter values are set empty. (LazyDataModel + "special" API-usage)

See original GitHub issue

As in the example below, after selecting a value from the selectcheckbox menu, the filter values are lost when the table is updated. It works fine with version 11.

<h:form>
      <p:dataTable var="customer" value="#{dtLazyView.lazyModel}" paginator="true" rows="10"
                   paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                   rowsPerPageTemplate="5,10,15" selectionMode="single"
                   selection="#{dtLazyView.selectedCustomer}"
                   id="customerTable" widgetVar="_customerTable">

        <p:column headerText="Name" sortBy="#{customer.name}">
          <h:outputText value="#{customer.name}"/>
        </p:column>
        <!-- This filter hides correctly, but is not working when updated -->
        <p:column headerText="country " sortBy="#{customer.country}" filterBy="#{customer.country.name}">
          <f:facet name="filter">
            <p:selectCheckboxMenu id="multiple" value="#{dtFilterView.selectCountries}" style="min-width: 15rem"
                                  multiple="true" scrollHeight="250" updateLabel="true">
              <p:ajax event="change" process="@this" update="@form:customerTable"/>
              <f:selectItems value="#{dtLazyView.countries}"/>
            </p:selectCheckboxMenu>
          </f:facet>
          <h:outputText value="#{customer.country.name}"/>
        </p:column>
      </p:dataTable>

    </h:form>

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:32 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
christophs78commented, Nov 3, 2022

Even better - provide a (probably failing) integration test. Use https://github.com/primefaces/primefaces/commit/e7333816c420b260c504f8bc9238ae7059902521 as kind of template. (This way we ensure not to break existing usecases. PrimeFaces, JSF and DataTable allow for so many usecases. Integration tests help us to avoid breaking other existing usecases while trying to fix or enhance other ones.)

1reaction
djmjcommented, Nov 4, 2022

Yes that is correct.

Simplified example

Here simple test files i send @mertsincan at PRO support. In this test intentional i show the filterYear property again in the header facet and also use a second component outside the table to double check.

This shows, that the filterYear is correctly pushed to the bean but on update the input component in the filter facet is not updated with that value.

<p:column filterBy="#{car.year}" sortBy="#{car.year}">
	<f:facet name="header">
		<!-- check if filterYear is correctly pushed to bean on change -->
		<h:outputText value="Year: #{testDataTableFilterAjaxBean.filterYear}" />
	</f:facet>
				
	<f:facet name="filter">
		<!-- 1. push filterYear to bean
			2. update table
			3. selectOneMenu looses value and shows 'NONE' but in facet header we see its set -->						
		<p:selectOneMenu id="filterYear" value="#{testDataTableFilterAjaxBean.filterYear}" size="4" > 
			<f:selectItem itemLabel="None" itemValue="#{null}" />
			<f:selectItems value="#{testDataTableFilterAjaxBean.years}" />		
			<p:ajax process="@this" update="@form"/>							
		</p:selectOneMenu>
	</f:facet>
				
	<h:outputText value="#{car.year}" />
</p:column>
test-datatable-onemenu-ajax-lostvalue-client

test-dataTableFilter-ajax-lost.zip

Read more comments on GitHub >

github_iconTop Results From Across the Web

13.0.0 Milestone - GitHub
DataTable: when it is updated, the filter values are set empty. (LazyDataModel + "special" API-usage) 12.0.1 defect Something isn't working.
Read more >
How to avoid datatable to clear filter in columns on updating ...
I have a datatable with columns, each columns having filter. I am using Lazy data model in order to populate the table.
Read more >
Filterable datatable with lazy loading is empty [SOLVED]
I created a p:dataTable like below. The dataTable is rendered okay, but without data. All columns are visible and there are no JavaScript ......
Read more >
Filter Data Table - UiPath Documentation Portal
Set Browser Data. Mouse Scroll ... XL-DBP-027 - Empty Use Excel File Activity ... Filter. Filter Pivot Table. Find First/Last Data Row. Find/Replace...
Read more >
Range Filter: Reduce of empty array with no initial value
I have added the range_filter plugin to my DataTable $.fn.dataTable.ext.search.push( function( settings, data, dataIndex ) { var min ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found