Using the page event with p:dataList in PrimeFaces

前端 未结 2 1248
粉色の甜心
粉色の甜心 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');
       }
     }
    

提交回复
热议问题