Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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
ExtJS 3.3.1-如何在Ext.Template中获取数组中的每个元素_Extjs - Fatal编程技术网

ExtJS 3.3.1-如何在Ext.Template中获取数组中的每个元素

ExtJS 3.3.1-如何在Ext.Template中获取数组中的每个元素,extjs,Extjs,我是ExtJS新手,尝试使用此示例作为我代码的基础: 我有一个perl*.pm文件,它处理我的后端功能 我自己编写了一个函数,在行选择时调用,使用my*.pm检索信息并覆盖detailPanel,如下所示: var getInfo = function(id){ var conn = new Ext.data.Connection(); conn.request({ url: request_url, params: { _state: request_stat

我是ExtJS新手,尝试使用此示例作为我代码的基础:

我有一个perl*.pm文件,它处理我的后端功能

我自己编写了一个函数,在行选择时调用,使用my*.pm检索信息并覆盖detailPanel,如下所示:

var getInfo = function(id){
var conn = new Ext.data.Connection();
conn.request({
    url: request_url,
    params: {
        _state: request_state,
        _action: 'get_id_info',
        id: id
    },
    callback: function(options, success, response){
        var responseHash = Ext.decode(response.responseText);
        var detailPanel = Ext.getCmp('detailPanel');
        myTpl.overwrite(detailPanel.body, responseHash);
    }

});
};
我的responseHash包含几个键,其中一些键的值是数组

目前,我的detailPanel看起来是这样的:

// define a template to use for the detail view
var myTplMarkup = [
    "values related to this key_name: {key_name}"
];
var myTpl = new Ext.Template(myTplMarkup);
// define a template to use for the detail view
var myTpl = new Ext.XTemplate(
    '<p>item(s) related to this id:',
        '<tpl for="key_name">',
        '<p><a href="---url_template---{.}" target="_blank">{.}</a></p>',
        '</tpl></p>'
);
这将在详细视图中打印与该键相关的值,并用逗号分隔

现在,我想分别访问每个值,并将其合并到一个链接中,并在详细视图中显示该链接

我该怎么做


谢谢

我将Ext.Template更改为Ext.XTemplate,并使用此示例访问数组中的每个项并为其生成超链接:

我发现XTemplate上的Ext文档非常有用

现在我的代码看起来是这样的:

// define a template to use for the detail view
var myTplMarkup = [
    "values related to this key_name: {key_name}"
];
var myTpl = new Ext.Template(myTplMarkup);
// define a template to use for the detail view
var myTpl = new Ext.XTemplate(
    '<p>item(s) related to this id:',
        '<tpl for="key_name">',
        '<p><a href="---url_template---{.}" target="_blank">{.}</a></p>',
        '</tpl></p>'
);