Skip to main content

Order by a column

By providing the order method with a column name and order (default ascending) you can change the sort order.

import canvasDatagrid from 'canvas-datagrid';
import data from '/data.json';

const app = document.getElementById('app');
const gridElement = document.createElement('div');
const grid = canvasDatagrid({
  parentNode: gridElement,
  data,
});

app.append(gridElement);

grid.order(grid.schema[0].name, 'asc');