Splitting datatable into multiple columns (grid view)

Splitting datatable into multiple columns (grid view)

Skarv1Skarv1 Posts: 12Questions: 1Answers: 0
edited August 2013 in General
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:

------ -- -- --
------ -- -- --
------ > -- -- --
------ -- -- --

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    This is not something which is supported in DataTables - sorry. It probably is possible to use a "master" table and then clone elements on each draw, but it sounds rather inefficient to me.

    Allan
  • Skarv1Skarv1 Posts: 12Questions: 1Answers: 0
    edited August 2013
    Thanks for the quick reply. I guess the solution you're mentioning is somewhat in the likes of this post:
    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. :)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Very cool indeed, but as I say, I'm afraid not something that I can support at the moment. I am interested in what you come up with, but v1.10 is taking my priority at the moment rather than experimental new features. Sorry.

    Allan
This discussion has been closed.