Format
Object
Formatting depends on localization. About localization read Localization
The main formatting field is date
.
For that it is used properties: edit
, read
, write
.
Another extra property is inputFn
.
inputFn
formats displaying value.
inputFn
is used for almost all fields.
Example: Date formatting
...
items: [{
type: 'date',
label: 'Birthday',
name: 'birthday',
emptyText: 'm.d.Y',
format: {
read: 'm.d.Y',
write: 'm.d.Y',
edit: 'm.d.Y'
}
...
Example: inputFn
...
items: [{
type: 'number',
label: 'Salary',
name: 'salary',
emptyText: '$80,000',
format: {
inputFn: function salaryInputFn(value){
value = value.toString().replace('$', '').replace(/\,/g,'').replace('-', '').replace('.', '');
if(value.length === 0){
value = '';
}
else if(value.length > 6){
value = value.substr(0, 6);
value = '$' + value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
else{
value = '$' + value.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
return value;
}
}
...