what are the minimum steps to deploy slickgrid with node.js?

node v12.20.2
npm v6.14.11

not much in the way of node.js examples out there for slickgrid.

here is what has eventually led me to getting stuck with Uncaught TypeError: myslickgrid is not a function at runtime.

$ npm install slickgrid
$ npm install jquery
$ npm install jquery-ui
var jQuery = require('jquery');

function test() {
    var myslickgrid = require('slickgrid');

    var columns = [
        {id: "column1", name: "Column1", field: "column1"},
        {id: "column2", name: "Column2", field: "column2"}
    ];

    var data = [
        {
            column1: "Test1",
            column2: "Test2"
        }
    ];

    var options = {
        enableCellNavigation: true,
        enableColumnReorder: false
    }

    myslickgrid("mydiv", data, columns, options);
}

2 thoughts on “what are the minimum steps to deploy slickgrid with node.js?”

  1. There’s a few things that seems wrong which is probably not helping

    1. Your require('slickgrid') is wrong, it should be require('slickgrid/slick.grid') and it should be outside of the function on the first couple lines of imports.
    2. The other thing you’re missing is jQueryUI import, I use it with the minified dist package from npm with require('jquery-ui-dist/jquery-ui')
    3. You also have to instantiate it and you’re not, you need to call new Slick.Grid(...) and you cannot alias that, it really has to Slick.Grid because that is what is defined in the jQuery namespace
    4. this last step is an extra but if you have linting issues, you might need to make Slick as an available global variable in your eslint to avoid red squiggly, in my case with TypeScript I do it this way declare const Slick: any; to avoid linting errors.

    If you still have problem, you can check my TypeScript implementation here that is used for my Slickgrid-Universal library (which is wrapper on top of the 6pac/SlickGrid fork)

    Reply

Leave a Comment