"it doesn't work" is not a good description of the problem.
The row number of the child within its parent and the index of the parent are required in the call to setFirstColumnSpanned().
For each first level item with children you want to iterate over all of its children set their first column spanned. This is two loops.
Bookmarks