Using the page event with p:dataList in PrimeFaces

前端 未结 2 1229
粉色の甜心
粉色の甜心 2021-01-07 06:17

Does a support the page event? I\'m trying to use the page event in the following way (blocking a

相关标签:
2条回答
  • 2021-01-07 06:35

    As I have seen from the source code that page event is not supported by dataList, on the other hand dataGrid supports it.

    The solution would be monkey patching as we don't have control on rewriting the original JS file, you can hook an event before the handling of the pagination and after it, all by javascript.

    Here's an example: assuming your dataList widgetVar is dataListWV

    //making sure the widgetVar is ready to be used    
    setTimeout(dataListPaginationExtraEvents, 1000);    
    
    function dataListPaginationExtraEvents() {
       var odlHandlePagination = PF('dataListWV').handlePagination;
    
       PF('dataListWV').handlePagination = function(newState) {
          //before
          console.log('start fetch');
          //calling original pagination 
          odlHandlePagination.apply(this, [newState]);
          //after
          console.log('end fetch');
       }
     }
    
    0 讨论(0)
  • 2021-01-07 06:39

    As of PrimeFaces 5.3 final (community release), the page event is supported in <p:dataList>

    The following picture is taken from the PrimeFaces user guide 5.3 (page 146).

    There is no mention of Ajax behavior events in previous guides.

    The page event as mentioned in the question works flawlessly in PrimeFaces 5.3 final (community release).

    • https://github.com/primefaces/primefaces/issues/687
    • https://github.com/primefaces/primefaces/commit/52b6c22eb37eca62a979d204f2030c82b795d472#diff-b651ae3f3b6abb0cf6945a9c589fa68aR98
    0 讨论(0)
提交回复
热议问题