import {
DataDen,
DataDenHeaderDateFilterRenderer,
DataDenHeaderNumberFilterRenderer,
DataDenHeaderSelectFilterRenderer,
DataDenHeaderTextFilterRenderer
} from "data-den-core";
const rows = [
{ car: 'Honda', model: 'Civic', year: '01/05/2013', price: 28000 },
{ car: 'Mitsubishi', model: 'Lancer', year: '01/05/2013', price: 56000 },
{ car: 'Porsche', model: 'Boxster', year: '09/02/2020', price: 31000 },
{ car: 'Toyota', model: 'Celica', year: '16/12/2010', price: 18000 },
{ car: 'Kia', model: 'Ceed', year: '14/03/2024', price: 28000 },
{ car: 'Ford', model: 'Focus', year: '04/07/2014', price: 24000 },
{ car: 'Ford', model: 'Focus', year: '16/12/2010', price: 24000 },
{ car: 'Porsche', model: 'Boxster', year: '24/01/2015', price: 31000 },
{ car: 'Mitsubishi', model: 'Lancer', year: '14/09/2006', price: 18000 },
{ car: 'Kia', model: 'Sportage', year: '01/03/2024', price: 24000 },
];
const options = {
columns: [
{
field: 'car',
headerName: 'Car',
filter: true,
filterRenderer: DataDenHeaderTextFilterRenderer,
filterOptions: {
method: 'includes',
debounceTime: 500,
caseSensitive: false,
},
},
{
field: 'model',
headerName: 'Model',
cellRenderer: DataDenDefaultCellRenderer,
filter: true,
filterRenderer: DataDenHeaderSelectFilterRenderer,
filterOptions: {
method: 'includes',
listOptions: [
{ label: 'Civic', value: 'civic' },
{ label: 'Lancer', value: 'lancer' },
{ label: 'Boxster', value: 'boxster' },
{ label: 'Celica', value: 'celica' },
{ label: 'Sportage', value: 'sportage' },
{ label: 'Focus', value: 'focus' },
],
},
},
{
field: 'year',
headerName: 'Year',
filter: true,
filterRenderer: DataDenHeaderDateFilterRenderer,
filterOptions: {
method: 'equals',
debounceTime: 500,
dateParserFn: (dateString) => {
const dateParts = dateString.split('/').map((part) => Number(part));
const [day, month, year] = dateParts;
return new Date(year, month - 1, day);
},
},
},
{
field: 'price',
headerName: 'Price',
filter: true,
filterRenderer: DataDenHeaderNumberFilterRenderer,
filterOptions: {
method: 'equals',
},
},
],
rows: rows,
rowHeight: 32,
};
const gridEl = document.getElementById('grid');
const dataDen = new DataDen(gridEl, options);