4

I'm trying to figure out how to have more than 1 data table (filtering AJAX paginating table like the entry view in the Control Panel) on a page but there's a problem; the div used for pagination is hard coded in the JS. This means that the pagination icons all get stacked onto a single table and becomes unusable.

I've taken a look at the Table class and using a data source but am unclear if that will allow for multiple data tables.

Any ideas?

2

Your best bet is to construct your own data tables - see the DataTables site

I have used DataTables to make multiple tables on a page - for example, my HooKan module has nine large tables on a page. Once you have had a look at how DataTables works, come back if you have any problems implementing

| improve this answer | |
  • The big downsides to that is it requires reinventing a lot of boilerplate code and inclusion of another datatables library. I'm hoping to use the existing libraries and code that's bundled with EE if at all possible. – Eric Lamb Nov 27 '12 at 21:21
  • Sorry I could not help with that. All my attempts to use the the datatables code bundled with EE have ended in frustration. I don't even know why they include the example in the dev docs, since they don't exactly explain how to use it in a more general sense. – John de Beer Nov 27 '12 at 21:33
0

Maybe you should re-think why you want multiple datatables on a page. To me that sounds like a UI disaster, especially if they were stacked vertically.

That said, you should be able to do it using the built in table class (note: from memory, it actually uses tablesorter, not datatables). I highly recommend using that class over rolling your own, it makes your code much simpler. I expect you would need to make sure there are no overlapping POST parameters between the two tablesorters.

I don't really understand your pagination issue (can you elaborate?), but knowing PHP and JS I bet there is a way for you to override it. If all else fails, just dig around in the EE source til you find a solution!

| improve this answer | |
  • I disagree; it comes down to presentation. Sure, stacking them all on top of each other would be an eye sore but delimiting them with categorized accordions would make things way more pleasant. – Eric Lamb Nov 28 '12 at 19:33
  • Also, I've dug through the source and found that the datatables library included with EE has been customized and has a hard coded call to "document.getElementById("filter_pagination");" so there's literally no way to create additional pagination placements. – Eric Lamb Nov 28 '12 at 19:38
  • Ew, accordions :P Nah, I won't pass judgement until I actually see what you're building. I wish EL would bundle the unencrypted JS so we can actually see what's going on. It sounds like you may have hit a wall though. It's usually easy to monkey patch javascript functions, but not if you can't read the source. You could try emailing them and pester them to make the filter pagination ID a parameter? – Adrian Macneil Nov 28 '12 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.