PDA

View Full Version : [OPEN-1283] swf.setDataProvider error when multiple charts use same datastore



Hannah
20 Sep 2010, 1:31 PM
Ext version tested:


Ext 3.2.1



Adapter used:


ext



css used:


only default ext-all.css





Browser versions tested against:


IE8
FF 3.6.10 (firebug 1.5.4 installed)



Operating System:


Windows Server 2003



Description:


In Firefox, clearing a datastore when two charts are loaded in different panels using that datastore causes an error.



Test Case:
Use this javascript file with the index.html template provided in the Tutorials section (http://www.sencha.com/learn/Tutorial:Basic_Page_Setup)


Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';

dataStore = new Ext.data.ArrayStore({
fields: ['number', 'value1', 'value2'],
data: []
});

Ext.onReady(function() {
Ext.chart.Chart.CHART_URL = 'ext/resources/charts.swf?nocache=' + Math.floor(Math.random()*10000);

var chart1 = new Ext.chart.LineChart({
store: dataStore,
url: Ext.chart.Chart.CHART_URL + 'a',
xField: 'number',
series: [{
type: 'line',
yField: 'value1'
}]
});

var chart2 = new Ext.chart.LineChart({
store: dataStore,
url: Ext.chart.Chart.CHART_URL + 'b',
xField: 'number',
series: [{
type: 'line',
yField: 'value2'
}]
});

var chartPanel1 = new Ext.Panel({
title: 'Chart 1',
id: 'chart1',
items: chart1
});

var chartPanel2 = new Ext.Panel({
title: 'Chart 2',
id: 'chart2',
items: chart2
});

var cardPanel = new Ext.Panel({
layout: 'card',
region: 'center',
activeItem: 0,
items: [
chartPanel1,
chartPanel2
]
});

var changeButton = new Ext.Button({
text: 'Change Chart',
listeners: { click: {fn: changeCharts}}
});

var newValuesButton = new Ext.Button({
text: 'Generate New Values',
listeners: { click: {fn: newValues}}
});

var buttonPanel = new Ext.Panel({
region: 'north',
height: 50,
items: [
changeButton,
newValuesButton
]
});

viewport = new Ext.Viewport({
layout: 'border',
items: [
buttonPanel,
cardPanel
]
});

function changeCharts() {
var newActiveItem = 1;
if (cardPanel.getLayout().activeItem.id == 'chart2') {
newActiveItem = 0;
}
cardPanel.getLayout().setActiveItem(newActiveItem);
}

function newValues() {
dataStore.removeAll();
for (var i = 0; i < 5; i++) {
var newRec = new Ext.data.Record({
fields: [{name: 'number'}, {name: 'value1'}, {name: 'value2'}]
});
newRec.data['number'] = i;
newRec.data['value1'] = Math.floor(Math.random()*100);
newRec.data['value2'] = Math.floor(Math.random()*100);
dataStore.add(newRec);
}
}
});
Steps to reproduce the problem:


Change the displayed chart at least once
Click the 'Generate New Values' button



The result that was expected:


Datastore could be cleared without a problem, even with two charts accessing it



The result that occurs instead:


The removeAll() method generates a 'this.swf.setDataProvider is not a function' error



Screenshot or Video:


attached



Debugging already done:


Removing the callback, i.e. using removeAll(true), allows the new data to load properly, but the error still occurs later

Condor
14 Jan 2011, 3:54 AM
Duplicate of this report (http://www.sencha.com/forum/showthread.php?78788-OPEN-197-3.0.0-svn-5208-this.swf.setDataprovider-is-not-a-function).

Please try the VisibilityMode plugin on the card panels (as described here (http://www.sencha.com/forum/showthread.php?78788-OPEN-197-3.0.0-svn-5208-this.swf.setDataprovider-is-not-a-function&p=406116#post406116)).

Hannah
9 Mar 2011, 11:26 AM
Thanks, that worked.