我熟悉使用函数来确定使用xtemplate的特定条件,但不知道如何在没有条件if语句的情况下直接调用函数.
例如,我的代码想要将一些字符附加到我在xtemplate中使用的字符串中.我认为最好的方法是在渲染xtemplate时附加字符.
var myTpl = new Ext.XTemplate(
'<tpl for=".">',
'<tpl if="this.isThumbnailed(thumbnailed) == true">',
'<img src=this.getThumbUrl(rawThumbUrl)/>', //this call to function does not work, also tried variations of this.
'</tpl>',
'</tpl>',
{
isThumbnailed : function(thumbnailed) {
return ...;
},
getThumbUrl : function(rawThumbUrl) {
//... //this function does not get called.
return ...;
}
}
)
Run Code Online (Sandbox Code Playgroud) 我有一个应该加载用户信息的jsonstore.我将HTTPRequest作为GET,但是当我最终使用参数加载存储时,它会自动更改为POST请求.
我之前做过类似的事情,除了它是一个常规的数据存储区,并且请求保持为GET.当提供params来执行POST请求时,jsonstore的默认行为是什么?
var userDisplayStore = new Ext.data.JsonStore({
url : myurl/userinfo,
method : 'GET',
fields : ['firstName', 'lastName', 'email', 'userName'],
id : 'user-display-store',
root : 'data'
});
userGridPanel.on('rowclick', function(grid, dataIndex, event) {
var dataRow = grid.getStore().getAt(dataIndex);
userDisplayStore.load({
params : {username : dataRow.data.username}
});
});
Run Code Online (Sandbox Code Playgroud)