Hola amigos,
Me encuentro intentando desarrollar una pequeña aplicación utilizando ExtJs 4. Me ha costado mucho y e ido resolviendo cada problema siguiendo manuales, estudiando en la red y buscando todas las veces que ha sido necesario, pero ahora simplemente ya no se que hacer y acudo a ustedes para ver si me puede orientar y ayudar un poco.
El Listener funciona bien si lo renderizo con Extjs.getBody, pero me reporta error si lo renderizo a "Sebas" (el Id del panel)... Igual les cuento que se muy poco de JS y por lo mismo no me doy cuenta de qué sucede.
Gracias por la ayuda que me puedan dar.
Código Javascript
:
Ver originalExt.onReady(function(){
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'divisions.json'
},
root: {
text: 'Países/Divisiones Político-Administrativas',
expanded: true
}
});
//*******************************************
var tree = Ext.create('Ext.tree.Panel', {
ìd: 'Paises',
region: 'west',
width: '40%',
height: 200,
store: store,
style: 'margin: 2px',
border:3
});
//*******************************************
//*****************
function GetContentSel2($sel) {
$result2 = "";
$found2 = false;
$fh2 = fopen("http://127.0.0.1/piaalc/WebIndig_ENG/MIGR_Int/DivsAdm.txt","r");
do {
$aux2 = trim(fgets($fh2));
$aux2 = explode("=",$aux2);
if ($aux2[0] == $sel) {
$found2 = true;
$result2 = $aux2[1];
console.log( $result2);
}
} while (($found2 == false) & (FEOF($fh2)));
fclose($fh2);
return $result2;
}
function verificar()
{
$kk="sebas";
return "retorno de funcion en PHP";
}
//*****************
var border = Ext.create('Ext.container.Viewport', {
layout: 'border',
defaults:{
columnWidth:0.5,
layout:'anchor',
border: 0
},
items: [{
region: 'north',
height: '16%',
layout:'fit',
border: 0,
html: '<iframe style="height: 100%; width: 100%; border: 0" frameborder="0" src="BcoDatosIndig_ESP.htm"></iframe>'
},{
region: 'south',
height: '42%',
border:0
},{
region: 'west',
width: '30%',
layout: 'fit'
},{
region: 'east',
width: '30%',
layout: 'fit'
},{
title: 'Migración interna de pueblos indígenas',
region: 'center',
width: 400,
height: 200,
border:1,
layout: 'hbox',
items:[Ext.create('Ext.tree.Panel', {
ìd: 'Paises',
region: 'center',
width: '40%',
height: 200,
store: store,
style: 'margin: 2px',
border:3,
listeners:{//Listeners apuntando a cada node
select:function(t,record)
{
var a = '';
var b = '';
var a = record.parentNode.raw.name;
var b = record.raw.name;
if (a == 'Brasil'){
console.log('La variable "a" almacena : ', a);
console.log('La variable "b" almacena : ', b);
//*****************************************************
function renderTopic(value, p, record) {
return Ext.String.format(
'<a href="http://sencha.com/forum/showthread.php?t={2}" target="_blank">{0}</a>',
value,
record.data.forumtitle,
record.getId(),
record.data.forumid
);
}
var grid = Ext.create('Ext.grid.Panel', {
width: '60%',
height: 200,
//collapsible: true,
//title: 'ExtJS.com - Browse Forums',
store: store_Tabs,
loadMask: true,
selModel: {
pruneRemoved: false
},
multiSelect: true,
viewConfig: {
trackOver: false,
emptyText: '<h1 style="margin:20px">No matching results</h1>'
},
// grid columns
columns:[{
xtype: 'rownumberer',
width: 50,
sortable: false
},{
tdCls: 'x-grid-cell-topic',
text: "Tabulados",
dataIndex: 'title',
flex: 1,
renderer: renderTopic,
sortable: true
}],
renderTo: Sebas
});
//*****************************************************
} else {
console.log('Se eligio un nodo diferente');
}
}
}, // Termina el listeners
}),{
title:"Mi panel",
ìd: 'Sebas',
xtype:'panel',
region: 'east',
width: '60%',
height: 200,
//store: store_b,
style: 'margin: 2px',
border:3
}
]
}]
});
border.show();
});