问题
i have a grid nested, i want to get the row inside one of them but i cant.
This is the gridpanel code:
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);
}
}
});
in HTML the grid seems:
<td class="x-grid-subtable-cell" style="width:100px">
<div id="ext-element-5" class="x-grid-cell-inner">
text
</div>
</td>
si i tried e.getTarget('.x-grid-subtable-cell')
, e.getTarget('.x-grid-subtable-cell.x-grid-cell-inner')
, e.getTarget('.x-grid-subtable-cell div')
but never i obtain the value inside the row of the sub-table where you doubleclick. What am i doing wrong?
(Maybe im doing a newbie question, but im learning javascript and its not yet my fort).
Thank you in advance.
来源:https://stackoverflow.com/questions/26016240/get-row-from-a-nested-grid