Skip to content

Commit

Permalink
chore: improve demo for date filtering (#1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding authored Nov 27, 2024
1 parent 8145a02 commit 1a46dab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/demo/src/examples/slickgrid/example1.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ <h3>
dataset.bind="dataset1"
on-aurelia-grid-created.trigger="aureliaGridReady($event.detail)">
</aurelia-slickgrid>
</div>
</div>

<hr />

Expand Down
6 changes: 4 additions & 2 deletions packages/demo/src/examples/slickgrid/example1.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { type AureliaGridInstance, type Column, type GridOption, Formatters } from 'aurelia-slickgrid';

import { zeroPadding } from './utilities';

const NB_ITEMS = 995;

export class Example1 {
Expand Down Expand Up @@ -89,8 +91,8 @@ export class Example1 {
title: 'Task ' + i,
duration: Math.round(Math.random() * 100) + '',
percentComplete: randomPercent,
start: new Date(randomYear, randomMonth + 1, randomDay),
finish: new Date(randomYear + 1, randomMonth + 1, randomDay),
start: `${zeroPadding(randomYear)}-${zeroPadding(randomMonth + 1)}-${zeroPadding(randomDay)}`,
finish: `${zeroPadding(randomYear + 1)}-${zeroPadding(randomMonth + 1)}-${zeroPadding(randomDay)}`,
effortDriven: (i % 5 === 0)
};
}
Expand Down
5 changes: 3 additions & 2 deletions packages/demo/src/examples/slickgrid/example40.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Aggregators,
type Column,
FieldType,
Filters,
Formatters,
type GridOption,
type Grouping,
Expand Down Expand Up @@ -40,8 +41,8 @@ export class Example40 {
{ id: 'title', name: 'Title', field: 'title', sortable: true, minWidth: 100, filterable: true },
{ id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true, minWidth: 100, filterable: true, type: FieldType.number },
{ id: 'percentComplete', name: '% Complete', field: 'percentComplete', sortable: true, minWidth: 100, filterable: true, type: FieldType.number },
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, exportWithFormatter: true, filterable: true },
{ id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso, exportWithFormatter: true, filterable: true },
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, exportWithFormatter: true, filterable: true, filter: { model: Filters.compoundDate } },
{ id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso, exportWithFormatter: true, filterable: true, filter: { model: Filters.compoundDate } },
{ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', sortable: true, minWidth: 100, filterable: true, formatter: Formatters.checkmarkMaterial }
];

Expand Down
4 changes: 4 additions & 0 deletions packages/demo/src/examples/slickgrid/utilities.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function zeroPadding(input: string | number) {
const number = parseInt(input as string, 10);
return number < 10 ? `0${number}` : number;
}

0 comments on commit 1a46dab

Please sign in to comment.