Load multiple datatables in the same page

Load multiple datatables in the same page

ferran_munozferran_munoz Posts: 28Questions: 7Answers: 0

Hello!

How I said in the main title, I have a project that contains almost 30 datatables in differents pages. But, lot of them maybe loads in the same page (for example, when I go to see the details of a user, I load 5-6 datatables).

Now I have all the code in the same page, repeat the code 5-6 times, and I don't want it. I'm working with Laravel, but this is not important, because if I work with ASP NET MVC will be the same. So, the question is: How it works for load more than a datatable in the same page for not repeat code?

I thought the possibility to create a base datatable (like a view) and inyect in the view like @include (or @viewbag in MVC), but I don't know if this is a good solution.

Any idea?

Replies

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    One option would be to set defaults where possible, see example here. Another approach would be to set all the defaults in an object, which you then clone and modify to suit the tables which are different to the norm.

    There are a few examples and threads (here and here) on the forum too, so would be worth searching.

    Colin

  • ferran_munozferran_munoz Posts: 28Questions: 7Answers: 0

    Amazing colin, I think that I use the solution of the first thread, making defaults values for every table (in fact, the only thing that change in the datatables are the data and columns, the other parameters are the same).

    With this solution the code will be more clean.

    Thanks!

This discussion has been closed.