Can we have a column field with numbers only data but need to add validation on it, only positive integers should enter not negative not 0 value.
columns : [
{ text: 'Quantity', field: 'quantity', type: 'number' },
],
Hi,
Here is an example of how you achieve it
{
text : 'Age',
field : 'age',
width : 100,
editor : {
type : 'number',
listeners : {
action(event) {
console.log('fire');
const { value, source : numberField } = event;
if (value < 1) {
numberField.setError('Invalid Input');
} else {
numberField.clearError();
}
},
input(event) {
const { value, source : numberField } = event;
if (value < 1) {
numberField.setError('Invalid Input');
} else {
numberField.clearError();
}
}
}
}
}
Please check docs
https://bryntum.com/products/grid/docs/api/Core/widget/NumberField#events
https://bryntum.com/products/grid/docs/api/Core/widget/NumberField#function-setError
https://bryntum.com/products/grid/docs/api/Core/widget/NumberField#function-clearError
Here is the output
Wouldn't just setting the min
on the field be easier?
https://www.bryntum.com/products/grid/docs/api/Core/widget/NumberField#config-min
editor : {
min : 0
}