The properties of Webix components can be changed after initialization each time the define() method is applied to them. It takes the following arguments:
The method can be applied to any object pointed to by its ID:
// sets a new height for the list
$$("mylist").define("height", 300);
$$("mylist").refresh();
// changes the label of the button
$$("button1").define("label", "New value");
$$("button1").refresh();
The method can also take a hash of property-value pairs to change multiple properties at once:
// sets new width and height for the list
$$("mylist").define({
width:300,
height: 300
});
$$("mylist").refresh();
Webix has a rich API that allows performing various operations and can be used instead of the define() method. So we advise you to look up a suitable method in the API reference before use the define() method.
In order that new properties came into force, you should apply either of these methods to the redefined component:
$$("layout").define("rows", [ {view:"button", ...}, {view:"label", ...} ]);
$$("layout").reconstruct();
The reconstruct() method is out-of-date. We recommend you to use more modern techniques of rebuilding components that are described in the section Rebuilding Application Layout.
The desired configuration parameter can be accessed and changed through the config property as well.
//reading height
var height = $$("myList").config.height;
//setting new height
$$("myList").config.height = 400;
$$("muList").resize();
Changing component properties via config comes in handy when getting and setting values for component items that are stored in an array that is a property itself.
Defining width of a datatable column
webix.ui({
view:"datatable",
id:"mytable",
columns:[
{ id:"col_1", header:"Film title",width:200},
{ id:"col_2", header:"Released" , width:80}
]
})
// reading width of the 1st column
var colWidth = $$("mytable").config.columns[0].width; // 200
// resizing the 1st column
dtable.resize();
Type with data-containing components denotes the way each data item looks like, rather than look-and-feel of the whole component.
webix.ui({
view:"list",
type:{
width:200, // item width
height: 50
},
width: 250 // list width
..
});
To redefine the width of the item, you should use the customize() method instead of the define() one. The arguments are the same:
$$("list1").customize({ width:210}); // item width changes
$$("list1").refresh();
More about Type Implementation.
Back to top