Ext.draw.Component动态添加图形之后没反应

liuqxyvtc 发布于 2014/10/23 14:34
阅读 387
收藏 0
Ext.onReady(function(){
		var arry = [{
	    	type: 'rect',
	        width: 100,
	        height: 30,
	        x:1050,
	        y:25,
	        radius: 10,
	        fill: 'green',
	        opacity: 0.5,
	        stroke: 'red',
	        'stroke-width': 2
	    },{
	        type: "text",
	        text: "营销系统",
	        fill: "green",
	        x:1155,
	        y:40,
	        font: "18px monospace"
    	},{
	        type: "text",
	        text: "生产系统",
	        fill: "green",
	        x:1155,
	        y:80,
	        font: "18px monospace"
    	},{
	        type: "text",
	        text: "调度系统",
	        fill: "green",
	        x:1155,
	        y:120,
	        font: "18px monospace"
    	},{
	    	type: 'rect',
	        width: 100,
	        height: 30,
	        x:1050,
	        y:65,
	        radius: 10,
	        fill: 'yellow',
	        opacity: 0.5,
	        stroke: 'red',
	        'stroke-width': 2
	    },{
	    	type: 'rect',
	        width: 100,
	        height: 30,
	        x:1050,
	        y:105,
	        radius: 10,
	        fill: 'red',
	        opacity: 0.5,
	        stroke: 'red',
	        'stroke-width': 2
	    }]
	    
	var flowComponent = Ext.create('Ext.draw.Component', {
		id:'flowComponent',
	    viewBox: false,
	    items: arry
	});
	
	var button = Ext.create('Ext.Button',{
			text:'增加图元',
			handler : function(){
					alert("添加前"+arry.length);//打印出长度是6
					arry.push({
					    	x:652,
							y:20,
					        type: 'circle',
					        fill: '#79BB3F',
					        radius: 20
		    		});
		    
		    alert("后"+arry.length);//打印出长度是7
		    Ext.getCmp('flowComponent').render();
		}
	})
	//流程图panel
	var panel = Ext.create('Ext.panel.Panel',{
		items:[flowComponent,button],
		renderTo : Ext.getBody()
	});
})



加载中
返回顶部
顶部