I want to use Div structure in Datatables instead

2019-09-20 10:38发布

问题:

I want to use Datatables with div structure instead of tables. the purpose is to meet design requirements. is there any possible way or any alternative for that?

回答1:

No you will not be able to do this... The core of Datatables will only work on table elements and child thead tbody tfooter tr td th elements... You will need to write your own pagination code to handle your div cards or download another plugin... jquery Datatables will not support that.

here is a good one? This even looks like jquery datatables pagination. https://esimakin.github.io/twbs-pagination/#demo



回答2:

Sure you can! I think what you're looking for is manipulating the dom object of Datatables!


A simple example of adding some divs to the table ->

$('#example').dataTable({
    dom: '<"top"i>rt<"bottom"flp><"clear">'
});

This will give you wrapper divs around table content, filters and the whole table. You can learn more by reading the official documentation from their website.
Here's a link to the documentation ->https://datatables.net/reference/option/dom