ColVis Grouped Fields in Popup Menu

ColVis Grouped Fields in Popup Menu

vol7ronvol7ron Posts: 43Questions: 11Answers: 0

Does the Buttons 'colvis' extension have the ability to group fields through as a menu option?

The former extension allowed an easy way to exclude fields (by index) as well as combine columns into one option of the ColVis popup menu:

    colVis: {
        exclude: [0,1,4,5,22],
        groups: [{
            title: "Sensitive Fields",
            columns: [ 9, 10, 11 ]
        }]
    }

The colvisGroup shows how one might create a toggle button, but that doesn't show in my full colvis popup menu and as a standalone button is separate from the options in the colvis menu.

Imagine having a "Student" table with ~25 fields. Some of those fields might be a subgroup (e.g., address info, phone numbers, classes). This requires to have a lot of independent fields in the menu, but still one or two grouped fields in the menu as well.

This is the second time posting this question (the first doesn't seem to have saved). The original had linked to an example playgroup and an attempt with the new [non-working] Buttons/ColVis attempt. I don't think they're needed, but I can try and recreate upon request.

Answers

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin

    Hi,

    Yes indeed this can be done - you need to combine the colvisGroup button with a collection - e.g.:

    buttons: [{
      extend: 'collection',
      text: 'Columns',
      buttons: [
          {
            extend: 'colvisGroup',
            text: 'Office info',
            show: [ 1, 2 ],
            hide: [ 3, 4, 5 ]
         },
         ...
      ]
    ]
    

    These two examples might also be of some use:

    Allan

This discussion has been closed.