I have been trying to get SlickGrid to work, first in a svelte application, and then in a Vanilla Javascript one for testing, both built with Vite and where Slickgrid is installed via npm.
Even though Sortable is a dependency of Slickgrid, and is installed when SlickGrid is installed (ie is present in the node modules), running a basic page in dev mode comes up with:
Uncaught (in promise) ReferenceError: Sortable is not defined
I have tried also manually installing SortableJS but of course it is already installed, and makes no difference.
It happens with both Typescript and Javascript repos, and occurs in dev and built modes with Vite.
The process to reproduce is:
- create new Vite project, Vanilla Javascript
npm installnpm i slickgrid- replace
main.jswith following code:
import './style.css'
import { SlickDataView, SlickGrid } from 'slickgrid'
document.querySelector('#app').innerHTML = `
<div id="myGrid">
</div>
`
const dataView = new SlickDataView({ inlineFilters: true });
const columns = [
{
name: "Address",
field: "address",
id: "address", // In most cases field and id will have the same value.
sortable: true
},
{
name: "Rating, in %",
field: "rating", // This and the following column read the same data, but can present it in a different way.
id: "rating_percent",
resizable: false
},
{
name: "Rating, in stars",
field: "rating",
id: "rating_stars"
}
];
const options = {}
const grid = new SlickGrid("#myGrid", dataView, columns, options);
- run the dev script and check browser console.