【问题标题】:EXTJS 3.4 HOW TO GET RECORD DATAVIEW ON selectionchangeEXTJS 3.4 如何在 selectionchange 上获取记录数据视图
【发布时间】:2016-11-17 19:46:58
【问题描述】:

使用Ext.DataView时如何获取selection change上的记录?

我想在 selectionchange 事件函数中获取值 'IdPrd'。

var tpl_ram = new Ext.XTemplate(
    '<ul>',
        '<tpl for=".">',
            '<li class="phone">',
                '<img width="64" height="64" src="data/catalogo/ramos/imagenes/{IdRm}/{IdRm}.jpg" />',
                '<strong>{NomRm}</strong>',
                '<span>{DescRm}</span>',
            '</li>',
        '</tpl>',
    '</ul>');

var ramos_dw = new Ext.DataView({
    tpl: tpl_ram,
    store: ramos_productos,
    id: 'ramos_dw',
    itemSelector: 'li.phone',
    overClass: 'phone-hover',
    singleSelect: true,
    autoScroll: true,
    autoHeight: true,
    emptyText: 'SIN RESULTADOS QUE MOSTRAR',
    listeners: {
        'click': function() {},
         selectionchange: {
            fn: function(dv, nodes) {
                //i want on selection get value 'IdPrd'
                var record = nodes[0];
                console.log("advert id - " + record.get('IdPrd'))
            }
        }
    }
});

【问题讨论】:

    标签: javascript extjs extjs3


    【解决方案1】:

    目前尚不清楚您商店中的模型是什么样的。但解决方案是先获取数据对象。

    所以代码是:

    var recordData = nodes[0].getData();
    // keep in mind that user can select more than 1 node --> nodes[0] 
    console.log("advert id - " + recordData['IdPrd'])
    

    您也可以简单地将debugger; 放入您的 selectionchange 函数侦听器中,并探索您在特定示例中获得的节点对象的确切外观。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-21
      • 1970-01-01
      • 1970-01-01
      • 2019-04-27
      • 2019-04-25
      • 2014-02-04
      相关资源
      最近更新 更多