Splitting datatable into multiple columns (grid view)
Splitting datatable into multiple columns (grid view)
Hi, first of all I'd like to state how impressed I am with DataTables and all its possibilities. At the moment, I am trying to divide my table into multiple rows, obtaining a grid view. After searching for an elegant solution, I found a simple and fast code snippet that splits the table elegantly and placed this within the "fnDrawCallback" function, but it destroys any consequent filtering. How should I do it in order to retain the filtering?
function splitTable(table_td, number_of_columns) {
var i, j;
for (i = 0, j = Math.ceil(table_td.length / number_of_columns); j < table_td.length; i++, j++)
$(table_td[i]).parent().append(table_td[j]);
}
Desired result:
------ -- -- --
------ -- -- --
------ > -- -- --
------ -- -- --
function splitTable(table_td, number_of_columns) {
var i, j;
for (i = 0, j = Math.ceil(table_td.length / number_of_columns); j < table_td.length; i++, j++)
$(table_td[i]).parent().append(table_td[j]);
}
Desired result:
------ -- -- --
------ -- -- --
------ > -- -- --
------ -- -- --
This discussion has been closed.
Replies
Allan
https://www.datatables.net/forums/discussion/6711/grid-mode
The "splitTable" code snippet above brought me quite a long way in getting my DataTables table to look and behave much like the popular Masonry/Isotope plugins ( http://isotope.metafizzy.co/ ), so if I were able to get the filtering to work as well, it would be just perfect. :)
Allan