我想将透明度应用于之前保存的图层,为此我有一个包含列出的所有图层的treepanel,并且通过itemcontextmenu事件我放置了一个滑块来管理不透明度,当我选择第一个元素来更改不透明度时该图层效果很好,但是当我选择另一个项目/元素时,不透明度仍然使用第一个元素设置.....
例如: 选择第一个元素(工作正常):
选择了下一个元素(它仍使用前一个元素):
我有这段代码:
initComponent: function() {
var anchoPanatallaRes = window.screen.width;
var altoPantallaRes = window.screen.height;
var anchoTOC = 330;
var altoTOC = 473;
if (anchoPanatallaRes <= 1024) {
anchoTOC = 282;
altoTOC = 373;
}
function addUrl(value, p, record) {
return value ? Ext.String.format(
'<a href="'+value+'"target="_blank"'+'>Ver metadato'+'</a>'
):'';
}
var treeStore = Ext.getStore('capa');
var tree = Ext.create('Ext.tree.Panel', {
title: '',
id: "arbolTabla",
width: anchoTOC,
height: altoTOC,
reserveScrollbar: true,
loadMask: true,
useArrows: true,
rootVisible: false,
store: 'capa',
allowDeselect : true,
border : true,
animate: true,
columns: [{
xtype: 'treecolumn',
text: 'Capa',
flex: 5,
sortable: true,
dataIndex: 'titulo'
},{
text: 'Metadato',
flex: 2,
dataIndex: 'metadato',
renderer: addUrl
}],
tbar: [{
labelWidth: 100,
xtype: 'triggerfield',
id: 'campoBusquedaCapa',
fieldLabel: 'Nombre capa:',
triggerCls: 'x-form-clear-trigger',
onTriggerClick: function() {
this.reset();
treeStore.clearFilter();
this.focus();
},
enableKeyEvents: true
}, {
xtype : 'button',
icon: 'css/app/imagenes/lupa.png',
cls : 'apagarCapas',
width: 20,
height: 25,
id : 'btnApagarCapas',
action: 'apagarCapas',
tooltip : 'Apagar todas las capas',
padding:0
}]
});
Ext.apply(this, {
title: 'TABLA CONTENIDO',
constrain: true,
header : {
titlePosition : 2,
titleAlign : 'center'
},
closable : false,
width : anchoTOC,
height : altoTOC,
x : 20,
y : 270,
layout : 'fit',
animCollapse : true,
collapsible : true,
collapseDirection : Ext.Component.DIRECTION_LEFT,
items: [tree],
});
tree.on('itemcontextmenu', function(view, record, item, index, event, eOpts) {
event.stopEvent();
if (record.data.leaf != false) {
slider = Ext.create('Ext.slider.Single', {
id: 'sliderOpacidad',
hideLabel: true,
floating: true,
width: 200,
minValue: 0,
maxValue: 100,
value : 70,
listeners: {
change: function (newValue, thumb, eOpts ){
var capaBuscar = record.data.id;
var controladorUbicar = aplicacion.getController("ControlUbicar");
var capa = controladorUbicar.buscarcapa(capaBuscar);
console.log(capa);
capa.setOpacity(thumb/100);
},
blur: function() {
slider.setVisible(false);
capaBuscar=null;
}
}
});
slider.showBy(item, 'tl-tl', [event.getX() - view.getX(), 12]);
}
}, this);
this.callParent(arguments);
}
答案 0 :(得分:0)
我解决了我的问题,更改了属性ID&#39; sliderOpacidad&#39;滑块到&#39; record.data.id&#39;