How to colspan rowspan in Datatables?

眉间皱痕 提交于 2020-01-05 05:33:04

问题


I am trying to use colspan and rowspan attributes with jQuery Datatables where a product sku can span 2 rows and a week can span 2 columns creating a table that looks like this.

is this possible?


回答1:


I'm afraid that's not doable. (Colspan might be, but rowspan just goes so much against the idea of DT that it won't be possible).

However, looking at the table I wonder if you could not combine the 4 values into a single cell, like "KPI1, KPI2, KPI3, KPI4". You could even display these 4 values as href, each linking to a different details-page etc. There are many things possible when using custom render-functions, check out https://datatables.net/reference/option/columns.render




回答2:


jQuery DataTables supports ROWSPAN and COLSPAN attributes in the table header as long as there is at least one cell for each column. See Complex header example for more details and demonstration.

jQuery DataTables plug-in doesn't support ROWSPAN and COLSPAN attributes in the table body by default.

However there is a RowsGroup plugin for jQuery DataTables that groups cells together to make them look like as if ROWSPAN attribute is used.

See this example for code and demonstration.

See jQuery DataTables – ROWSPAN in table body TBODY for more details.



来源:https://stackoverflow.com/questions/48493452/how-to-colspan-rowspan-in-datatables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!