2017-10-20 160 views
0

我正在寻找为网格中的列返回子字符串。在传递的值是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()); 
    }, 

回答

0

想通了:

renderer: function (value, meta) { 
       return Ext.util.Format.substr(value, value.lastIndexOf("/")+1, value.length); 
0

这将是这样做的另一种方法是使用:

renderer: v => v.split('/').pop() 
+0

因为我需要更多渲染器,所以我保留了我的解决方案,但是您的工作完美无缺。 渲染器:函数(值,元){ meta.style =“color:blue;”; ... – TigerDave

相关问题