Available only in PRO Edition
The described feature is available in the Webix Pro edition.
If you need to give some additional information for the content of a datatable row, you can add a subrow after it.
To add a subrow into Datatable, use the subrow property. As a parameter, it takes a template with the names of data properties that should be shown in the subrow:
{
view:"datatable",
subrow:"Rating: #rating#, Category: #category#",
...
}
In the columns configuration you should specify the template property with the value like "{common.subrow()} #title#", where:
columns:[
{ id:"title", header:"Title",
template:"{common.subrow()} #title#", width:220 },
{ id:"year", header:"Year", width:100, sort:"int"},
{ id:"votes", header:"Votes", width:100, sort:"int"}
]
Related sample: Sub-rows in DataTable
If the text in a subrow is too long, you can set the subRowHeight property with the auto value. It will force the subrow to adjust its height to the size of the text:
webix.ui({
view:"datatable",
subrow:"#details#",
columns:[
...
],
subRowHeight:"auto",
data:[
{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790,
details:`Long text Long text Long text Long text Long text Long text
Long text Long text Long text Long text Long text Long text Long text
Long text Long text Long text Long text Long text `},
...
]
});
Related sample: Sub-rows in DataTable: Size to Data
If you need to alter the text in the subrow dynamically, you should access the related data item and apply changes to it.
For example, you render the details data property in a subrow:
{
view:"datatable", id:"dt1",
// the data specified in the "details" property will be rendered
subrow:"#details#",
data:[
{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790,
details:`Long text Long text Long text Long text Long text Long text
Long text Long text Long text Long text Long text Long text Long text
Long text Long text Long text Long text Long text `},
...
]
}
To change it, you should use the getItem method that will return data item object by the specified id. And then specify the new text for the details property of this item:
{
// return the object of the id with id "1" and set
// the text "One line" in the "details" property
$$("dt1").getItem("1").details = "One line";
$$("dt1").refresh()
}
Related sample: Sub-rows in DataTable: API
There's a couple of functions you can use to manipulate the subrows in a datatable:
$$("myDatatable").openSub(id);
$$("myDatatable").closeSub(id);
Back to top