关于DOM element with id in Element cache is not the same as element in the Dom解决方法

来源:互联网 发布:广电总局封网络机顶盒 编辑:程序博客网 时间:2024/05/20 16:01

ExtJS 5.1.1在使用统计图调用时,代码如下:

var graph0101 = Ext.create('Ext.chart.CartesianChart',{id:'graph_0101',insetPadding: {top: 60, bottom: 10, left: 40, right: 20},store:loaderObj.chartStore,width: 900,height: 420,animate: true,shadow: true,legend:{position:'bottom'},axes:[{type:'numeric',position:'left',grid:true,fields:['items'],            grid: {                odd: {                    opacity: 1,                    fill: '#ddd',                    stroke: '#bbb',                    'stroke-width': 1                }            },            minimum:0,            maximum:total_xmsl+100,title:{text: '目数(个)', fontSize: 16}},{type:'category',title:{text: '年份', fontSize: 16},position:'bottom'}],series: [    {    type: 'bar',    xField:'year',    yField:['items'],gutter: 20,groupGutter: 10,axis: 'left',highlight: true,            showInLegend :  true,        label : {        field :     ['items'],//标签字段名        contrast: true,  //统计图里的字反亮显示        display : 'outside',//标签显现方式        color:'blue',       font : '12px 宋体',//字体       orientation:'horizontal',        renderer : function(v){//自定义标签渲染函数        return v+'个' ;        }        },                }],sprites: {type:'text',text:Ext.getCmp('txt_charttitle').getValue(),font:'25px 宋体',width:300,height:35,x:150,y: 40}});


,产生如下图的错误



解决方法,在以上代码前加上以下代码

if(!Ext.Object.isEmpty(Ext.getCmp('graph_0101'))){Ext.destroy(Ext.getCmp('graph_0101'));}

就可以解决该错误。




阅读全文
0 0
原创粉丝点击