Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 列表的itemTpl上的sencha touch::substr()_Javascript_List_Sencha Touch_Itemtemplate_Substr - Fatal编程技术网

Javascript 列表的itemTpl上的sencha touch::substr()

Javascript 列表的itemTpl上的sencha touch::substr(),javascript,list,sencha-touch,itemtemplate,substr,Javascript,List,Sencha Touch,Itemtemplate,Substr,在sencha touch中,当我的模板构建时,如何缩短列表对象中的长名称 itemTpl: '{firstName} {lastName}', thnx 编辑:谢谢你的尝试,伙计们!我的问题是我使用 plugins: [new app.plugins.editableList()], // by WhiteFox AS 这似乎造成了麻烦。而没有插件的简单 { xtype: 'list', ... itemTpl: new Ext.XTemplate( '<tpl

在sencha touch中,当我的模板构建时,如何缩短列表对象中的长名称

itemTpl: '{firstName} {lastName}',
thnx

编辑:谢谢你的尝试,伙计们!我的问题是我使用

plugins: [new app.plugins.editableList()], // by WhiteFox AS
这似乎造成了麻烦。而没有插件的简单

{ 
  xtype: 'list',
  ...
  itemTpl: new Ext.XTemplate(
    '<tpl for=".">',
        '<div>{[this.shortenName(values)]}</div>',
    '</tpl>',
    {
        shortenName: function(values) {
            return values.firstName.substr(0, 5);
        }
    }
),
...}  
{
xtype:'列表',
...
itemTpl:new Ext.XTemplate(
'',
“{[this.shortenName(values)]}”,
'',
{
短名称:函数(值){
返回值.firstName.substr(0,5);
}
}
),
...}  

似乎有效。

为什么不将所需的值存储在数据存储中?如果它只是您想要的最后一个首字母,请将其存储在数据存储中并调用:

itemTpl: '{firstName} {lastInitial}',

您可以在模板中嵌入javascript。如果你有一些函数“truncate”,你可以这样做

{[truncate(values.firstName,5) + " " + truncate(values.lastName,5)]}

在商店里我需要全名。在列表中,它只需要显示一个缩短的字段,如string.substr(0,16)+“…”,您可以根据姓氏字段将最后一个首字母作为计算字段添加到模型中吗?这样,您就可以在模型上同时拥有姓氏和姓氏首字母。