Login

Snippets by yuvi

Snippet List

A basic view for working with jQuery dataTables plugin

jQuery dataTables is a fantastic and powerful client-side plugin, which has many capabilities. There are many libraries out there that easily integrate it with django with little to no effort. However, they provide everything out of the box, which isn't always the most flexible solution. I also think beginners have a lot to learn from not using already created tools. So, finding the general examples out there lacking, I though I'd hatch out a quick example of how to very basically integrate the two. I supply two lists at the top which define how to order the fields and which are searchable (quite similar to the one defined in the admin site) and later everything is figured from there. Of course, for a little more complex implementation (say using a method instead of a field) this will not work (since getattr doesn't automatically call a function if it is a function), but this snippet isn't supposed to provide everything but a very basic usage example, which can be very quickly expended in any way needed. Anyway, this snippet should work on all django versions and all dataTables versions without a hitch. last note- I use `cStringIO` with `json.dump` out of good personal experience with that settings, though it might not be the best way to serialize the data. Good luck, share use and enjoy, ~yuvi

  • django
  • dataTables
Read More

yuvi has posted 1 snippet.