Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
id: 'delete', field: 'id',
formatter: Formatters.deleteIcon,
minWidth: 30,
maxWidth: 30,
// use onCellClick OR grid.onClick.subscribe which you can see down below
onCellClick: (args: OnEventArgs) => {
console.log(args);
alert(`Deleting: ${args.dataContext.title}`);
}
},
{ id: 'title', name: 'Title', field: 'title', sortable: true, type: FieldType.string, editor: Editors.longText, minWidth: 100 },
{ id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true, type: FieldType.number, editor: Editors.text, minWidth: 100 },
{ id: 'complete', name: '% Complete', field: 'percentComplete', formatter: Formatters.percentCompleteBar, type: FieldType.number, editor: Editors.integer, minWidth: 100 },
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, sortable: true, minWidth: 100, type: FieldType.date, editor: Editors.date },
{ id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso, sortable: true, minWidth: 100, type: FieldType.date, editor: Editors.date },
{ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', formatter: Formatters.checkmark, type: FieldType.number, editor: Editors.checkbox, minWidth: 100 }
];
this.gridOptions = {
asyncEditorLoading: false,
autoEdit: this.isAutoEdit,
autoResize: {
containerId: 'demo-container',
sidePadding: 15
},
editable: true,
enableCellNavigation: true
};
}
editor: {
model: Editors.date
}
}, {
id: 'effort-driven',
name: 'Effort Driven',
field: 'effortDriven',
filterable: true,
type: FieldType.boolean,
filter: {
model: Filters.singleSelect,
collection: [{ value: '', label: '' }, { value: true, label: 'True' }, { value: false, label: 'False' }]
},
formatter: Formatters.checkmark,
editor: {
model: Editors.checkbox
},
minWidth: 70
}, {
id: 'prerequisites',
name: 'Prerequisites',
field: 'prerequisites',
filterable: true,
formatter: taskFormatter,
minWidth: 100,
sortable: true,
type: FieldType.string,
editor: {
// We can load the "collection" asynchronously (on first load only, after that we will simply use "collection")
// 3 ways are supported (aurelia-http-client, aurelia-fetch-client OR even Promise)
// 1- USE HttpClient from "aurelia-http-client" to load collection asynchronously
customStructure: { label: 'name', value: 'code' },
collectionAsync: this.httpFetch.fetch(URL_COUNTRIES_COLLECTION),
}
}, {
id: 'effort-driven',
name: 'Effort Driven',
field: 'effortDriven',
filterable: true,
type: FieldType.boolean,
filter: {
model: Filters.singleSelect,
collection: [{ value: '', label: '' }, { value: true, label: 'True' }, { value: false, label: 'False' }]
},
formatter: Formatters.checkmark,
editor: {
model: Editors.checkbox,
},
minWidth: 70
}, {
id: 'prerequisites',
name: 'Prerequisites',
field: 'prerequisites',
filterable: true,
formatter: taskFormatter,
minWidth: 100,
sortable: true,
type: FieldType.string,
editor: {
// We can load the "collection" asynchronously (on first load only, after that we will simply use "collection")
// 3 ways are supported (aurelia-http-client, aurelia-fetch-client OR even Promise)
// 1- USE HttpClient from "aurelia-http-client" to load collection asynchronously
defineGrid() {
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title', sortable: true, type: FieldType.string, editor: Editors.longText },
{
id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true, type: FieldType.number, editor: Editors.text,
onCellChange: (args: OnEventArgs) => {
alert('onCellChange directly attached to the column definition');
console.log(args);
}
},
{ id: 'complete', name: '% Complete', field: 'percentComplete', formatter: Formatters.percentCompleteBar, type: FieldType.number, editor: Editors.integer },
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, sortable: true, type: FieldType.date/*, editor: Editors.date*/ },
{ id: 'finish', name: 'Finish', field: 'finish', formatter: Formatters.dateIso, sortable: true, type: FieldType.date },
{ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', formatter: Formatters.checkmark, type: FieldType.number, editor: Editors.checkbox }
];
this.gridOptions = {
asyncEditorLoading: false,
autoResize: {
containerId: 'demo-container',
sidePadding: 15
},
editable: true,
enableColumnPicker: true,
enableCellNavigation: true,
enableRowSelection: true
};
}
editor: {
model: Editors.date
}
*/
},
{
id: 'finish', name: 'Finish', field: 'finish',
formatter: Formatters.dateIso, sortable: true,
type: FieldType.date
},
{
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven',
formatter: Formatters.checkmark,
type: FieldType.number,
editor: {
model: Editors.checkbox
}
}
];
this.gridOptions = {
asyncEditorLoading: false,
autoResize: {
containerId: 'demo-container',
sidePadding: 15
},
editable: true,
enableColumnPicker: true,
enableCellNavigation: true,
enableRowSelection: true
};
}
editor: {
model: Editors.date
}
*/
},
{
id: 'finish', name: 'Finish', field: 'finish',
formatter: Formatters.dateIso, sortable: true,
type: FieldType.date
},
{
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven',
formatter: Formatters.checkmark,
type: FieldType.number,
editor: {
model: Editors.checkbox
}
}
];
this.gridOptions = {
asyncEditorLoading: false,
autoResize: {
containerId: 'demo-container',
sidePadding: 15
},
editable: true,
enableColumnPicker: true,
enableCellNavigation: true,
enableRowSelection: true
};
}