Row grouping by col-span instead of inserting rows

Row grouping by col-span instead of inserting rows

doganmehdoganmeh Posts: 4Questions: 1Answers: 1

Referring to this example, would it be possible to create grouping by col-span instead of inserting rows? It is called row-grouping but actually desired affect is column grouping, that is to group columns with same values in a given column.

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Not really I'm afraid. The example injects rows into the table on each draw to perform the grouping, which is fairly easy since HTML tables are row based. Injecting columns would be a lot harder, as you'd need to tidy up, and also deal with the header and footer.

    Having said that, there is this legacy plug-in which only works when using server-side processing (since the DOM is recreated for the tbody on each draw). That might be an option for you.

    Allan

  • doganmehdoganmeh Posts: 4Questions: 1Answers: 1

    I did not mean injecting a column.

    Here is what I mean: First, display the column being grouped, don't hide it.. Second, iterating through the rows as it is now, whenever a different value comes across on the grouped column, save a reference to it.. for repeating values set hidden and count.. whenever another different value comes across, update the referenced cell's col-span, reset counter and the reference.. iterate..

    Would a scenario like this work?

    The biggest advantage of this look would be that since grouped column is exposed you can click to it to sort.. as of know it is not intuitive to click on the injected row to reset ordering.

  • doganmehdoganmeh Posts: 4Questions: 1Answers: 1

    It should also be possible to add some classes whenever grouping changes, and do some fancy things with CSS.

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    I see what you mean. That is what the legacy plug-in I linked to does. However, it isn't possible to do that with client-side processing currently. It probably is possible, but I think it would be really quite complicated and isn't something I've tried to do myself.

    Allan

This discussion has been closed.