问题
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