Creating view within function

I want to create an ui (datatable or pivot) based on a value of a form control, after the form is submitted. I tried the following, within form_submit() function that is triggered byclicking the submit button:

// outType is the RichSelect value from the submitted form

switch(outType) {

case “datatable”:

var results = {container: “output_div”,view:“datatable”,id:“results”,“export”:true, height:600, url:dataUrl };

break;

case “pivot”:

var results = {container: “output_div”,view:“pivot”,id:“results”,url:dataUrl,columnWidth:90,“export”:true,autoWidth:true,rows:[“age”, “sex”, “action”],columns:[ params.groupby ],values:[{ name:“Cnt”, operation:“sum” }],filters:[]};

break;

}

webix.ui(results);

but I receive the following error in the console.

NS_ERROR_NOT_INITIALIZED

I couldn’t find any reference to a similar case in the forum, so I will appreciate if you can hopefully show me the correct way of doing this.

Thx

I’ve solve it with removeView and addView.

The original code is correct as well

http://webix.com/snippet/cdee46c7

The problem can be caused by missed output_div container ( it can be missed on the page or not rendered yet)

if you want to change UI dynamicall - it better to user addView | removeView or use mutliview pattern, where both components are initialized and only one of them is visible

Yes, addView | removeView works like a charm. How about adding an external object like Highcharts?

The idea is to have two columns in layout:
col-1 : Parameters
col-2 : Output

Based on selected report type, I can display datatable or pivot in output column using addView. But when the report is an Highcharts object, obviously this approach doesn’t work.

Any workaround for this?

Thx in advance

You can add template view with div tag inside and init highchart component in the DIV

Or, you can wrap the hihgchart in the custom view. Similar to next component s