Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createGrid (el, v) {
const personsDataSource = generatePersonsDataSource(1000000)
const startTime = new Date()
const grid = new cheetahGrid.ListGrid({
parentElement: el,
header: [
{ field: 'check', caption: '', width: 50, columnType: 'check', action: 'check' },
{ field: 'personid', caption: 'ID', width: 85 },
{
field: 'stars',
caption: 'Class',
width: 150,
columnType: new cheetahGrid.columns.type.IconColumn({
name: 'star'
}),
style: {
color: 'gold'
},
action: new cheetahGrid.columns.action.InlineMenuEditor({
options: [
{ value: 1, classList: 'stars', html: '<i class="material-icons">star</i>' },
{ value: 2, classList: 'stars', html: '<i class="material-icons">star</i>'.repeat(2) },
{ value: 3, classList: 'stars', html: '<i class="material-icons">star</i>'.repeat(3) },
{ value: 4, classList: 'stars', html: '<i class="material-icons">star</i>'.repeat(4) },
{ value: 5, classList: 'stars', html: '<i class="material-icons">star</i>'.repeat(5) }
]
})
},
{
action: new cheetahGrid.columns.action.SmallDialogInputEditor({
classList: 'helper-text--right-justified',
helperText (value) {
return `${value.length}/20`
},
inputValidator (value) {
return value.length > 20 ? `over the max length. ${value.length}` : null
}
})
},
{
field: 'lname',
caption: 'Last Name',
width: '20%',
minWidth: 150,
action: new cheetahGrid.columns.action.SmallDialogInputEditor({
classList: 'helper-text--right-justified',
helperText (value) {
return `${value.length}/20`
},
inputValidator (value) {
return value.length > 20 ? `over the max length. ${value.length}` : null
}
})
}
]
},
{
field: 'progress',
caption: 'Progress',
width: '10%',
export function normalizeAction (action) {
if (action && typeof action !== 'string') {
if (typeof action === 'function') {
action = new cheetahGrid.columns.action.Action({
action
})
} else if (typeof action.actionName === 'string') {
action = new cheetahGrid.columns.action[action.actionName](action.option)
}
}
return action
}