action callbacks inside collection buttons not triggered and enabled: false ignored on nested button

action callbacks inside collection buttons not triggered and enabled: false ignored on nested button

bolkanbolkan Posts: 2Questions: 1Answers: 0

Hi,

I’m using DataTables v2 with the new layout.buttons configuration. I have a collection button with child buttons inside it. The problem is twofold:

The child buttons inside the collection render correctly in the dropdown, but clicking them does not trigger their action callbacks at all.

Setting enabled: false on these nested child buttons does not disable them on initialization as expected; they appear enabled.

Here is a minimal example showing the issue:

https://jsfiddle.net/24s0dvrz/

Questions:
Is this a bug or known limitation of DataTables v2 when using layout.buttons with collection buttons?

Should the action callbacks work on nested buttons as usual?

Should enabled: false disable nested buttons on initialization?

Thanks in advance for any clarification.

Answers

  • kthorngrenkthorngren Posts: 22,200Questions: 26Answers: 5,111
    edited July 28

    The action isn't being called because the collection buttons never become enabled. The button-selector you are using, ie actionsCollection.withdrawBtn:name, is not correct and won't select any button to enable/disable. You only need to provide the specific buttons name, for example withdrawBtn:name. Use this instead:

    table.button('withdrawBtn:name').enable(true);
    

    Updated test case:
    https://jsfiddle.net/47v1gywL/2/

    I added the datatables.css and buttons.css to show the styling of the buttons to see if they are enabled.

    Kevin

  • kthorngrenkthorngren Posts: 22,200Questions: 26Answers: 5,111
    edited July 28

    Setting enabled: false on these nested child buttons does not disable them on initialization as expected; they appear enabled.

    You have enable: false, on the top level button but it should be

    I commented out these lines so you can see the buttons.buttons.enabled does work on the collection buttons:

      // table.button('actionsCollection:name').enable(false);
      // table.button('withdrawBtn:name').enable(false);
      // table.button('writeoffBtn:name').enable(false);
    

    https://jsfiddle.net/wrstL0e9/

    Click Actions without selecting a row to see the disabled collection buttons.

    Kevin

  • bolkanbolkan Posts: 2Questions: 1Answers: 0

    Makes perfect sense. Maybe i have some problems with loading datatables.

    <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" asp-append-version="true">
    <link href="https://cdn.datatables.net/v/bs5/jq-3.7.0/jszip-3.10.1/dt-2.3.2/b-3.2.4/b-colvis-3.2.4/b-html5-3.2.4/b-print-3.2.4/date-1.5.6/r-3.0.5/rg-1.5.2/rr-1.5.0/sc-2.4.3/sl-3.0.1/sr-1.4.1/datatables.min.css" rel="stylesheet" integrity="sha384-qE0110NQMqud/TcrqtI6RPeJtWDuluLOKt7gxv7Q8RVkHOznCplyEj5NgDJr++ou" crossorigin="anonymous">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js" integrity="sha384-VFQrHzqBh5qiJIU0uGU5CIW3+OWpdGGJM9LBnGbuIH2mkICcFZ7lPd/AAtI7SNf7" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js" integrity="sha384-/RlQG9uf0M2vcTw3CX7fbqgbj/h8wKxw7C3zu9/GxcBPRKOEcESxaxufwRXqzq6n" crossorigin="anonymous"></script>
    <script src="https://cdn.datatables.net/v/bs5/jq-3.7.0/jszip-3.10.1/dt-2.3.2/b-3.2.4/b-colvis-3.2.4/b-html5-3.2.4/b-print-3.2.4/date-1.5.6/r-3.0.5/rg-1.5.2/rr-1.5.0/sc-2.4.3/sl-3.0.1/sr-1.4.1/datatables.min.js" integrity="sha384-ZCYwIl/ImmUya/McxBODB3pwx8bVyUpgF4DtAo83o6BeR/WKwY5b7xHzLIStFSYG" crossorigin="anonymous"></script>
    
  • allanallan Posts: 64,829Questions: 1Answers: 10,731 Site admin

    You probably will have done yesterday, but things should be back to normal now. Does the CDN link you are using load okay for you? It is loading here, but there are some reports of caching errors that are taking a little while to clear.

    Allan

Sign In or Register to comment.