Unknown button type: selected with Electron

Unknown button type: selected with Electron

ReiserReiser Posts: 2Questions: 1Answers: 0
edited May 2019 in Free community support

Hi,
I'm experimenting a bit with DataTables in an Electron app. Works fine so far, but I get an error with buttons (from the Select/Buttons example):
Unknown button type: selected .\node_modules\datatables.net-buttons\js\dataTables.buttons.js:832

renderer.js

`'use strict'

window.$ = window.jquery = require('../node_modules/jquery');
window.dt = require('../node_modules/datatables.net')();
window.select = require('../node_modules/datatables.net-select')();
window.buttons = require('../node_modules/datatables.net-buttons')();

var demodata = [
.....
]

function init() {
    $('#tokenlist').DataTable({
        dom: 'Bfrtip',
        buttons: [
            /*{
                text: 'Import',
                action: function ( e, dt, node, config ) {
                    alert('Import');
                }
            },
            {
                text: 'Export All',
                action: function ( e, dt, node, config ) {
                    alert('Export');
                }
            },
            {
                text: 'Check if Expired',
                action: function ( e, dt, node, config ) {
                    alert('Check');
                }
            },*/
            'selected',
            'selectedSingle',
            'selectAll',
            'selectNone',
            'selectRows',
            'selectColumns',
            'selectCells'
        ],
        columns: [
            {
                "orderable": false,
                "searchable": false,
                "className": 'select-checkbox'
            },
            null,
            null,
            null,
            null,
            {
                "orderable": false,
                "searchable": false,
                "data": null,
                "defaultContent": "<button>Edit</button> <button>Del</button>"
            }
        ],
        select: {
            style:    'os'
            /*selector: 'td:first-child'*/
        },
        paging: false,
        "searching": false,
        className: 'compact',
        "order": [[ 1, "desc" ]],
        data: demodata
    });
}`

app.html

`<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <script src="js/renderer.js" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="css/select.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="css/buttons.dataTables.min.css">
    <link rel="stylesheet" href="css/style.css">
  </head>
  <body onload="init();">
    <div class='main' id='full'>

      <table id="tokenlist" class="display compact" style="width:100%">
        <thead>
            <tr>
                <th></th>
                <th>Status</th>
                <th>Identifier</th>
                <th>Token</th>
                <th>Date</th>
                <th>Operations</th>
            </tr>
        </thead>
        <tbody>
          <!--<tr>
              <td></td>
              <td>OK</td>
              <td>Row 1 Data 2</td>
              <td>Row 1 Data 3</td>
              <td>Row 1 Data 4</td>
              <td>Row 1 Data 4</td>
          </tr>-->
        </tbody>
    </table>
    </div>
  </body>
</html>`

When I make just custom buttons (like in the commented code above) it works.

Someone has an idea what I am doing wrong?

best regards

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @Reiser ,

    You would see that error if the Select extension extension isn't being loaded - you have it on your list of package, but according to the NPM page, it should be loaded like:

    require( 'datatables.net-select' )( window, $ );
    

    Could you try that for both Select
    and Buttons, please, and see if that does the trick.

    Cheers,

    Colin

  • ReiserReiser Posts: 2Questions: 1Answers: 0

    ahh bad mistake
    thank you that worked!

This discussion has been closed.