PrimeNG datatable checkbox selection with pagination

后端 未结 1 1540
青春惊慌失措
青春惊慌失措 2021-02-10 09:43

I\'m trying to bring a data table layout with pagination that has checkbox selection for data in it. I\'m able to select a page\'s data and when I move to another page, and sele

1条回答
  •  时光说笑
    2021-02-10 10:35

    The problem is discussed on github:

    DataTable selection with pagination

    To help you now:

    HTML:

        
               
        
    

    TS:

       class Test {
         private data: MyData[]; 
         selectedData: MyData[];
    
         onTableHeaderCheckboxToggle(event: any) {
          if (event.checked === true) {
             for (let m of this.data) {
                if (/* Make your test here if the array does not contain the element*/) {
                   this.selectedData.push(m);
                }
             }
          } else {
             this.selectedData.length = 0;
          }
        }
    

    0 讨论(0)
提交回复
热议问题