Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
: 'Second Value';
const handleChange = (e: any) => handleTextFieldChange(e.target.value);
return (
{column.DataType === ColumnDataType.BOOLEAN &&
BooleanInputOperators.map(option => (
<menuitem value="{option.Value}">
{option.Title}
</menuitem>
))}
);
};
Filterable: true,
Searchable: true,
Sortable: true,
}),
new ColumnModel('ShippedDate', {
DataType: ColumnDataType.DATE_TIME,
Filterable: true,
Sortable: true,
}),
new ColumnModel('ShipperCity'),
new ColumnModel('Amount', {
DataType: ColumnDataType.NUMERIC,
Sortable: true,
}),
new ColumnModel('IsShipped', {
DataType: ColumnDataType.BOOLEAN,
Filterable: true,
Sortable: true,
}),
];
export default columns;
const columns = [
new ColumnModel('OrderID', {
DataType: ColumnDataType.NUMERIC,
IsKey: true,
Label: 'Id',
}),
new ColumnModel('CustomerName'),
new ColumnModel('ShippedDate', {
DataType: ColumnDataType.DATE_TIME,
}),
new ColumnModel('ShipperCity'),
new ColumnModel('Amount', {
DataType: ColumnDataType.NUMERIC,
}),
new ColumnModel('IsShipped', {
DataType: ColumnDataType.BOOLEAN,
}),
];
export default columns;
const getValue = (dataType: ColumnDataType, operator: CompareOperators, value: string, handleTextFieldChange: any) => {
switch (dataType) {
case ColumnDataType.DATE:
if (value) {
return formatDate(value, 'yyyy-MM-DD');
}
handleTextFieldChange(formatDate(new Date().toISOString(), 'YYYY-MM-DD'));
return '';
case ColumnDataType.DATE_TIME:
case ColumnDataType.DATE_TIME_UTC:
if (value) {
return formatDate(value, 'yyyy-MM-DD[T]HH:mm');
}
handleTextFieldChange(formatDate(new Date().toISOString(), 'yyyy-MM-DD[T]HH:mm'));
return '';
case ColumnDataType.BOOLEAN:
return operator === CompareOperators.NONE
? ''
: typeof value === 'boolean'
? value === true
? 'true'
: 'false'
: value;
default:
return operator === CompareOperators.NONE ? '' : value || '';
}
};
export const renderCellContent: any = (column: ColumnModel, row: any) => {
switch (column.DataType) {
case ColumnDataType.NUMERIC:
return row[column.Name] || 0;
case ColumnDataType.DATE:
return formatDate(row[column.Name]);
case ColumnDataType.DATE_TIME:
case ColumnDataType.DATE_TIME_UTC:
return formatDate(row[column.Name], 'M/d/yyyy h:mm a');
case ColumnDataType.BOOLEAN:
return row[column.Name] === true ? : ;
default:
return row[column.Name];
}
};
const columnRender = (column, item) => {
switch (column.DataType) {
case ColumnDataType.BOOLEAN:
return renderBoolean(column, item);
case ColumnDataType.STRING:
return renderString(column, item);
default:
return renderGeneral(column, item);
}
};