Reputation: 89
How I can apply on Ext a number renderer format to a number field like 1233453455647895 to split it in 4 blocks, like this 1233-4534-5564-7895
Any answer will be apreciated
The solution (thanks to @newmount and @Rajinder) is (Edited at 24/10/2013)
flex: 1,
dataIndex: 'IdMoviCaja',
text: 'Id',
renderer: function (value){
if (Ext.isEmpty(value)) return value;
else {
value = value.toString();
//Remove existing hyphen first
var rg = /([-])/g;
value = value.replace(rg, "");
//Insert hyphen
var re = /(\d{4})(?!$)/g;
value = value.replace(re, "$1" + "-");
return value;
}
}
Upvotes: 0
Views: 1124
Reputation: 1951
Not sure about using hyphen in number field, but you could use textfield and validate it. Regarding formatting see this fiddle : https://fiddle.sencha.com/#fiddle/155 (formatting happens on blur)
Upvotes: 0
Reputation: 346
I don't think this format is available in extjs. So, you have to write custom logic in column renderer like this:
renderer: function(value){
//custom logic to parse value and format it according to your requirement
return formattedString;
}
Upvotes: 1