I am basically trying to combine: http://forum.webix.com/discussion/3843/custom-compound-components/p1
with: http://forum.webix.com/discussion/3949/layout-absolute-x-y-positioning#latest
My code is below. When the New button is clicked, I am trying to dynamically attach a new widget to the absolute layout when the button is clicked. A new Widget will create a new SelectGroup view, and that SelectGroup will create a SelectRow, all in a nested fashion. However, all I am getting is a gray rectangle, and there are no errors in the console.
webix.protoUI({
name:'selectRow',
$init:function(config) {
console.log('selectRow.init');
config.cols = [
{ view:'select', options:[{id:0,value:''},{id:1,value:'1'},{id:2,value:'2'},{id:3,value:'3'}], click:function(value) {console.log('left = ' + value)}},
{ view:'select', options:[{id:0,value:''},{id:1,value:'>'},{id:2,value:'>='},{id:3,value:'='},{id:4,value:'<'},{id:5,value:'<='},{id:6,value:'!='}], click:function(value) {console.log('center = ' + value)}},
{ view:'select', options:[{id:0,value:''},{id:1,value:'1'},{id:2,value:'2'},{id:3,value:'3'}], click:function(value) {console.log('right = ' + value)}},
{ view:'select', options:[{id:0,value:''},{id:1,value:'A'},{id:2,value:'B'}], click:function(value) {console.log('junk = ' + value)}},
{ view:'button', type:'iconButton', icon:'fa-minus-circle', click:function(){console.log('click!')}}
];
}
}, webix.ui.layout);
webix.protoUI({
name:'selectGroup',
$init:function(config) {
this.$ready.push(this.addRow());
},
addRow:function() {
console.log('selectGroup.addRow');
this.config.cols.push({ view:'selectRow' });
}
}, webix.ui.layout);
webix.protoUI({
name:'widget',
$init:function(config) {
this.config.rows = [];
},
addGroup:function() {
console.log('container.addGroup');
this.config.cols.push({ view:'selectGroup' });
}
}, webix.ui.view);
webix.protoUI({
name:'abs',
$init:function(config){
this.$ready.push(this.render);
this.$view.style.position = 'relative';
},
addWidget:function() {
console.log('abs.addWidget');
this.config.cells.push({ view:'widget', x: 50, y: 50, w: 400, h: 300 });
this.render();
},
render:function() {
for (var i = 0; i < this.config.cells.length; i++) {
var cell = this.config.cells[i];
var d = webix.html.create('DIV');
d.style.position = 'absolute';
d.style.left = (cell.x || 0) +'px';
d.style.top = (cell.y || 0) +'px';
d.style.width = (cell.w || 0) +'px';
d.style.height = (cell.h || 0) +'px';
this.$view.appendChild(d);
webix.ui(cell, d);
}
}
}, webix.ui.view);
webix.ui({
rows: [
{
view: 'toolbar',
cols:[
{
view:'button',
value:'New',
width:100,
align:'left',
click: function() {
$$('canvas').addWidget();
}
}
]
},
{
id:'canvas',
view: 'abs',
cells:[]
}
]
});