- fixed NaN value is given fo rundefined input values;
This commit is contained in:
@@ -6,12 +6,17 @@ const DefaultCell = ({ getValue, row: { index }, column: { id }, table }) => {
|
||||
table.options.meta?.updateData(index, id, e.target.value);
|
||||
};
|
||||
|
||||
const onFocus = (e) => {
|
||||
e.target.select();
|
||||
}
|
||||
|
||||
return (
|
||||
<input
|
||||
disabled={disabled}
|
||||
value={initialValue ?? ''}
|
||||
onChange={(e) => table.options.meta?.updateData(index, id, e.target.value)}
|
||||
onBlur={onBlur}
|
||||
onFocus={onFocus}
|
||||
className="w-full px-2 py-1 border rounded"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ const LastRowCell = ({columnId, lastRows, columnMeta = {}, getColumnDataFn}) =>
|
||||
|
||||
if (columnMeta.enableFormula) {
|
||||
const getAllRowsValues = getColumnDataFn(columnId)
|
||||
.map(v => isEmpty(v) ? 0 : v);
|
||||
.map(v => isEmpty(v) || isNil(v) ? 0 : v);
|
||||
|
||||
if (cellValue === 'sum') {
|
||||
cellValue = sum(getAllRowsValues);
|
||||
|
||||
@@ -7,6 +7,10 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table })
|
||||
table.options.meta?.updateData(index, id, numValue);
|
||||
};
|
||||
|
||||
const onFocus = (e) => {
|
||||
e.target.select();
|
||||
}
|
||||
|
||||
const onChange = (e) => {
|
||||
if (e.target.value === 0 || !isNaN(e.target.value)) {
|
||||
table.options.meta?.updateData(index, id, e.target.value);
|
||||
@@ -19,6 +23,7 @@ const NumericFormulaCell = ({ getValue, row: { index }, column: { id }, table })
|
||||
disabled={disabled}
|
||||
value={initialValue ?? 0}
|
||||
onChange={onChange}
|
||||
onFocus={onFocus}
|
||||
onBlur={onBlur}
|
||||
step="any"
|
||||
className="w-full px-2 py-1 border rounded"
|
||||
|
||||
Reference in New Issue
Block a user