Plugin/DataGridReorderable

A plugin to make a DataGrid (and its subclasses, e.g. Spreadsheet) reorderable along columns and/or rows.

Example

JS
import Spreadsheet from 'komps/komps/spreadsheet.js'
import { reorderable } from 'komps/komps/data-grid/plugins.js'
Spreadsheet.include(reorderable)
new Spreadsheet({
    reorder: ['columns'],    // columns only; omit for both
    data: [...],
    columns: [
        { header: 'Name', width: 200 },
        { header: 'Pinned', width: 80, reorder: false } // opt a column out
    ]
})

Parameters

options : Object optional

Options added to the grid

reorder : boolean | string | Array optional

Enable reordering rows and columns. Pass "columns" or "rows" (or an array) for one axis; false to disable.

Events

Fired after a column reorder finishes (on pointerup).

Properties

fromIndex : number

original column index

toIndex : number

new column index

Fired after a row reorder finishes (on pointerup).

Properties

fromIndex : number

original row index

toIndex : number

new row index