ScrollView-Cannot read prop.'1'of undefined,on reconstruct()

Hello everybody
I have this code:

//multiview
{
   	//gravity:3, 
    view:"multiview", 
    cells:[
    	//scroll view errors
    	{
        	view: 'layout', 
			type: 'wide',
			id: 'ewmon_layout_main_content_errors_1',
			rows: [
				{
					view: 'scrollview', 
					scroll:"y",
					id:'ewmon_scroll_main_content_errors_1',
					content:{
						view: 'layout', 
						type: 'wide',
						id: 'prueba',
						rows:[{
							view:"toolbar",
							type:"none",
							elements:[{view:"label", label:"domain goew here"}]
						}]	
					}
				}
			]
		},
		...........

when I click on a button I should rebuild the layout “prueba” to generate something with this structure:
scroll[
toolbar1,
dataview1,
toolbar2,
dataview2,
toolbar3,
dataview3,
toolbar4,
dataview4,

]
so I wrote this code:

$$('prueba').define("rows", content);
$$('prueba').reconstruct();

where the content array is built recursivly by calling these 2 methods and pushing them into the array “content”:

var buildToolbar = function(domainId,domainCompany) {
	var data = {
		view:"toolbar", 
		type:"none",
		elements:[{view:"label", label:domainId + " ("+domainCompany+")"}]
	}
	return data;
}

var buildDataview = function(domainName,size) {
	var data = {
		view:"dataview",
		height:50,
		type:{
			template:"<span class='dhx_strong'>#type#</span><span class='dhx_light'>#number#</span>",
			height:30,
			width:20
		},
		url:"data/domainfields_" + ewmon_controller.currentUsername + "_" + ewmon_controller.currentPassword + "_"+domainName+".xml",
		datatype:"xml"
	}
	return data;
}

the $$(‘prueba’).reconstruct() generate an error with error stack:

Uncaught TypeError: Cannot read property '1' of undefined		touchui_debug.js:4709
dhx.protoUI._set_child_size										touchui_debug.js:4709
dhx.protoUI.$setSize											touchui_debug.js:4704
dhx.protoUI.$setSize											touchui_debug.js:6936
dhx.protoUI._set_child_size										touchui_debug.js:4739
dhx.protoUI._set_child_size										touchui_debug.js:4827
dhx.protoUI.$setSize											touchui_debug.js:4814
dhx.protoUI.reconstruct											touchui_debug.js:4568
data.view														EWmonGridErrorController.js:176
x.onreadystatechange											touchui_debug.js:2617

even if the data are generated correctly in fact when I resize the window I can see the components well created.

can you please tell me why I get this error, for what I see is due to size specification of the layout but I cannot find the way to solve it.

Thanks in advance for your help
Danilo

Hello,

The view can no be recreated by define method. You can try to use dhx.ui() method to create the new view (it can be layout) instead of another view in a certain layout.

For example

  • the new view configuration:

var new_view = {cols:[{},{}]};

  • there is some layout already created, and its id is “mylayout”

  • there is a certain view (for example its id is “oldViewId”) inside “mylayout”, and this view will be replaced with new_view:

dhx.ui(new_view,dhx.ui.get(“mylayout”),“oldViewId”);

So, layout “mylayout” is retained. The “oldViewId” view is not.

However, possibly the approach that you are using is not correct… If you just want to switch between different views, you may use “multiview” view:

dhtmlxTouch_v10_111114/samples/technical/multiview/01_init.html