So, the question really is whether the datatable can do this automatically or whether I have to manually figure out the spans parameters whenever the data changes, and somehow set that on the grid.
If I can’t get rid of the ‘round’ column, I’m ok with showing the data just for the parent node, and leaving the children cells in the round column blank.
The following column definition almost works:
{
id : “round”,
header : “Round”,
template:“Round #value#”
}
The parent cells show: ‘Round 1’ etc.
However the child cells show: ‘Round undefined’
If I could get the child cells to be blank then that would work fine for me.
So, I’m guessing I need to create a template function which knows if the current row is a parent or a child ??
Absent being able to configure a column spanning row in the component, it seems that it can only be done on the data, is that correct?
If so, it seems that there are 2 possibilities:
a) before passing the data to table.parse([rows]), by reshaping the data like this:
var data = [
data : [],
spans: []
]
b) After the table has grouped the data, using table.addSpan() .
I’ve noticed that the id of the group row changes, e.g to: id: 0$1, so, I’m wondering if it’s possible to go through the data, after the table has grouped the data, looking for ids that start: 0$, and then using addSpan() with those id’s ?
You want a table grouped by an attribute (e.g: ‘round’), and you want that grouping attribute to be shown as a row spanning all the columns, instead of a column.
Solution:
Set view: ‘treetable’.
Set the scheme property to configure the grouping attribute, and the column in the spanning row to place it in, see below under $group.
For that column, provide a template which will show data depending on whether it’s the group row, or a non-grouping row.
If you want that column to show no data when it is not in a grouping row, then a) set it’s width small, b) set its header to: ‘’, and c) return ‘’ from that template:
If you want the table to be open all the time, set table.openAll()