Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
minWidth: 30,
maxWidth: 30
// use onCellClick OR grid.onClick.subscribe which you can see down below
/*
onCellClick: (e: Event, args: OnEventArgs) => {
console.log(args);
this.alertWarning = `Deleting: ${args.dataContext.title}`;
}
*/
}, {
id: 'title',
name: 'Title',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
editor: {
model: Editors.longText,
validator: myCustomTitleValidator // use a custom validator
},
minWidth: 100,
onCellChange: (e, args) => {
console.log(args);
this.alertWarning = `Updated Title: ${args.dataContext.title}`;
}
}, {
id: 'title2',
name: 'Title, Custom Editor',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
{
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
};
}
},
{
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
};
}
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
};
}
minWidth: 30,
maxWidth: 30,
// use onCellClick OR grid.onClick.subscribe which you can see down below
onCellClick: (e: Event, args: OnEventArgs) => {
console.log(args);
if (confirm('Are you sure?')) {
this.aureliaGrid.gridService.deleteDataGridItemById(args.dataContext.id);
}
}
},
{
id: 'title', name: 'Title', field: 'title',
sortable: true,
type: FieldType.string,
editor: {
model: Editors.longText
}
},
{
id: 'duration', name: 'Duration (days)', field: 'duration',
sortable: true,
type: FieldType.number,
editor: {
model: Editors.text
},
onCellChange: (e: Event, args: OnEventArgs) => {
alert('onCellChange directly attached to the column definition');
console.log(args);
}
},
{
id: 'complete', name: '% Complete', field: 'percentComplete',
// use onCellClick OR grid.onClick.subscribe which you can see down below
/*
onCellClick: (e: Event, args: OnEventArgs) => {
console.log(args);
this.alertWarning = `Deleting: ${args.dataContext.title}`;
}
*/
}, {
id: 'title',
name: 'Title',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
editor: {
model: Editors.longText,
validator: myCustomTitleValidator // use a custom validator
},
minWidth: 100,
onCellChange: (e, args) => {
console.log(args);
this.alertWarning = `Updated Title: ${args.dataContext.title}`;
}
}, {
id: 'title2',
name: 'Title, Custom Editor',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
editor: {
model: CustomInputEditor,
// use onCellClick OR grid.onClick.subscribe which you can see down below
/*
onCellClick: (e: Event, args: OnEventArgs) => {
console.log(args);
this.alertWarning = `Deleting: ${args.dataContext.title}`;
}
*/
}, {
id: 'title',
name: 'Title',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
editor: {
model: Editors.longText,
validator: myCustomTitleValidator, // use a custom validator
},
minWidth: 100,
onCellChange: (e: Event, args: OnEventArgs) => {
console.log(args);
this.alertWarning = `Updated Title: ${args.dataContext.title}`;
}
}, {
id: 'title2',
name: 'Title, Custom Editor',
field: 'title',
filterable: true,
sortable: true,
type: FieldType.string,
editor: {
model: CustomInputEditor,
this.gridExtraService.highlightRow(args.row, 1500);
this.gridExtraService.setSelectedRow(args.row);
}
},
{
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
defineGrid() {
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title', filterable: true, type: FieldType.string },
{ id: 'duration', name: 'Duration', field: 'duration', sortable: true, filterable: true, type: FieldType.string },
{ id: '%', name: '% Complete', field: 'percentComplete', sortable: true, filterable: true, type: FieldType.number },
{ id: 'start', name: 'Start', field: 'start', filterable: true, type: FieldType.string },
{ id: 'finish', name: 'Finish', field: 'finish', filterable: true, type: FieldType.string },
{
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', maxWidth: 80, formatter: Formatters.checkmark,
type: FieldType.boolean,
minWidth: 100,
sortable: true,
filterable: true,
filter: {
searchTerm: '', // default selection
type: FormElementType.select,
selectOptions: [{ value: '', label: '' }, { value: true, label: 'true' }, { value: false, label: 'false' }]
}
}
];
for (let i = 0; i < NB_ITEMS; i++) {
multiSelectFilterArray.push({ value: i, label: i });
}
this.columnDefinitions = [
{ id: 'title', name: 'Title', field: 'title', filterable: true, sortable: true, type: FieldType.string, minWidth: 45 },
{
id: 'description', name: 'Description', field: 'description', filterable: true, sortable: true, minWidth: 50,
type: FieldType.string,
filter: {
type: FilterType.custom,
customFilter: new CustomInputFilter() // create a new instance to make each Filter independent from each other
}
},
{
id: 'duration', name: 'Duration (days)', field: 'duration', sortable: true, type: FieldType.number,
minWidth: 55,
filterable: true,
filter: {
collection: multiSelectFilterArray,
type: FilterType.multipleSelect,
searchTerms: [1, 10, 20], // default selection
// we could add certain option(s) to the "multiple-select" plugin
filterOptions: {
maxHeight: 250,
width: 175
}
}
},
{ id: 'complete', name: '% Complete', field: 'percentComplete', formatter: Formatters.percentCompleteBar, minWidth: 55, type: FieldType.number, filterable: true, sortable: true },
{ id: 'start', name: 'Start', field: 'start', formatter: Formatters.dateIso, filterable: true, sortable: true, type: FieldType.date, minWidth: 60 },