Need a special offer?Find out if your project fits.
+

Error re-creating component

Answered
Cleyton Barroso asked on March 24, 2017

Hello!
I'm having problems with flexmonster when creating a new pivot.
In my preview screen I have the following process:
When the user enters the view screen, I create an instance of flexmonster and inform the options.

var pivot = null;

var createCube = function(options, reload)
{
//check if exists instance of pivot
if (pivot)
{
flexmonster.clear();
}

//check if exists an intance of pivot or is reload operation
if (!pivot || reload)
{
pivot = $("#pivotContainer").flexmonster({
componentFolder: "/Content/js/flexmonster/",
global: {
localization: "loc/pr.json"
},
toolbar: true,
beforetoolbarcreated: customizeToolbar,
licenseKey: "@ConfigurationManager.AppSettings["flexMonsterKey"]"
});
}

pivot.setReport(options);
}

//create cube first time
createCube(options,false);

But, i have an process for reload the records in pivot, that executes the function createCube again.
 

$("#buttonReload").on("click",fuction(e) 
{
//call function, but send true for reload data;
createCube(options,true);
});

As I am reporting the reload value as true, the following code will be executed:

flexmonster.clear() ;

pivot = $("#pivotContainer").flexmonster({
componentFolder: "/Content/js/flexmonster/",
global: {
localization: "loc/pr.json"
},
toolbar: true,
beforetoolbarcreated: customizeToolbar,
licenseKey: "@ConfigurationManager.AppSettings["flexMonsterKey"]"
});

The pivot loads smoothly, but the menu options no longer work, and begin to display the following error in the console:
Uncaught TypeError: Cannot read property 'getOptions' of null
at FlexmonsterToolbar.chartsHandler (:3001/Content/js/flexmonster/toolbar/flexmonster.toolbar.js:213)
at HTMLAnchorElement.<anonymous> (:3001/Content/js/flexmonster/toolbar/flexmonster.toolbar.js:1607)
 

2 answers

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster March 27, 2017

Hello Cleyton,
Thank you for providing us with the code example. The issue really exists and we will prepare the necessary fix in the version 2.313 ETA Apr10. For now, we recommend you using another approach. There is no need to recreate the pivot object to reload the data or other configs. You can just use the setReport() API call to load new data and new configuration. Here is the link to our documentation - http://www.flexmonster.com/api/setreport/ and the jsFiddle example -http://jsfiddle.net/flexmonster/1dLjhu0s/
Please let us know if you have any questions left here.
Best regards,
Dmytro.

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster April 10, 2017

Hello Cleyton,
I am glad to inform you that the minor release 2.313 is available for download now.
You are welcome to update the component.
Kind regards,
Dmytro

Please login or Register to Submit Answer