-1

How to get the record on selection change when using Ext.DataView ?

I would like to get value 'IdPrd' in the selectionchange event function.

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'))
            }
        }
    }
});
pagep
  • 3,488
  • 1
  • 26
  • 47

1 Answers1

0

It's not clear how your model from your store looks like. But solution would be to get the data object first.

So the code would be:

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

You can also simply put debugger; into your selectionchange function listener and explore how exactly the nodes object which you get in your specific example looks like.

pagep
  • 3,488
  • 1
  • 26
  • 47