EXTJS为列值创建子字符串(返回后半部分)
问题描述:
我正在寻找为网格中的列返回子字符串。在传递的值是HTML链接,我想借字符串过去的最后一个“/”EXTJS为列值创建子字符串(返回后半部分)
{
header: 'Site',
width: 22,
sortable: true,
hideable:false,
renderer: function(v) {
return Ext.util.Format.substr(v, 1, 8); // I know this is how you do the substring, but how do you get the final . and the last array position?
},
dataIndex: 'site'
}
在返回的一切寻找这样的事情:
renderer: function(v) {
return Ext.util.Format.substr(v, v.lastIndexOf("/"), v.end());
},
答
想通了:
renderer: function (value, meta) {
return Ext.util.Format.substr(value, value.lastIndexOf("/")+1, value.length);
答
这将是这样做的另一种方法是使用:
renderer: v => v.split('/').pop()
因为我需要更多渲染器,所以我保留了我的解决方案,但是您的工作完美无缺。 渲染器:函数(值,元){ meta.style =“color:blue;”; ... – TigerDave