从嵌套网格中获取行

时间:2014-09-24 11:53:39

标签: javascript extjs datagrid extjs5

我有一个网格嵌套,我想在其中一个内部获取行但我不能。

这是网格面板代码:

Ext.create('Ext.grid.Panel', {
    renderTo: 'amenazas-grid',
    store: amenazaStore,
    width: 748,
    height: 598,
    title: '<bean:write name="informesAGRForm" property="nombreActivo"/>',
    plugins: [{
        expandOnDblClick: false,
        ptype: "subtable",
        pluginId: 'subtable',
        headerWidth: 24,
            columns: [{
            text: 'id_amenaza',
            dataIndex: 'id_amenaza',
            hidden: true,
            width: 100
        }, {
            width: 100,
            text: 'id_salvaguarda',
            dataIndex: 'id_salvaguarda'
        },
        {
            text: 'denominacion',
            dataIndex: 'denominacion',
            width: 100
        },{
            text: 'descripcion',
            dataIndex: 'descripcion',
            width: 100
        },{
            text: 'eficacia',
            dataIndex: 'eficacia',
            width: 100
        },
        ],
        getAssociatedRecords: function (record) {
            var result = Ext.Array.filter(
            salvaguardaStore.data.items,

            function (r) {
                return r.get('id_amenaza') == record.get('id');
            });
            return result;
        }
    }],
    collapsible: false,
    animCollapse: false,
    columns: [

        {
            text: 'ID',
            hidden: true,
            hideable: false,
            dataIndex: 'id'
        },   
        {
            text: 'Codigo',
            width: 50,
            sortable: true,
            hideable: false,
            dataIndex: 'codigo'
        },          
        {
            text: 'Denominación',
            width: 150,
            dataIndex: 'denominacion',
        },
        {
            text: ' Autenticidad',
            flex: 1,
            dataIndex: 'a_riesgo'
        },
        {
            text: 'Confidencialidad',
            flex: 1,
            dataIndex: 'c_riesgo'
        },
        {
            text: 'Integridad',
            flex: 1,
            dataIndex: 'i_riesgo'
        },
        {
            text: 'Disponibilidad',
            flex: 1,
            dataIndex: 'd_riesgo'
        },
        {
            text: 'Trazabilidad',
            flex: 1,
            dataIndex: 't_riesgo'
        },
        {
            text: 'Total',
            flex: 1,
            dataIndex: 'total_riesgo'
        }],
        listeners: {
            'rowdblclick': function (view, record, tr, columnIndex, e) {
                var cell = e.getTarget('.x-grid-subtable-cell');
                if (!cell) {
                    return;
                }
                var row = Ext.get(cell).up('tr');
                var tbody = row.up('tbody');
                var rowIdx = tbody.query('tr', true).indexOf(row.dom);

                var records = view.up('grid').getPlugin('subtable').getAssociatedRecords(record);

                var subRecord = records[rowIdx];
                alert(subRecord);
            }
        }
    });
HTML中的网格似乎是:

<td class="x-grid-subtable-cell" style="width:100px">
    <div id="ext-element-5" class="x-grid-cell-inner">
        text
    </div>
</td> 

我试过e.getTarget('.x-grid-subtable-cell')e.getTarget('.x-grid-subtable-cell.x-grid-cell-inner')e.getTarget('.x-grid-subtable-cell div'),但我从未获得双击的子表行内的值。我究竟做错了什么?

(也许我正在做一个新手问题,但我正在学习javascript,它还不是我的堡垒)。

提前谢谢。

0 个答案:

没有答案