如何在Ext上将数字呈现器格式应用到象1233453455647895这样的数字字段中,将其分割成4个块,如下面的1233-4534-5564-7895
任何答案都将被接受。
解决方案(感谢@newmount和@Rajinder)是(2013年10月24日编辑)
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;
}
}发布于 2013-10-24 09:46:29
不确定在number字段中使用连字符,但是可以使用textfield并验证它。关于格式化,请参阅此小提琴:https://fiddle.sencha.com/#fiddle/155 (格式设置发生在模糊)
发布于 2013-10-24 07:11:25
我认为这种格式在extjs中是不可用的。因此,您必须在列呈现器中编写如下自定义逻辑:
renderer: function(value){
//custom logic to parse value and format it according to your requirement
return formattedString;
}https://stackoverflow.com/questions/19553149
复制相似问题