morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
208 stars 64 forks source link

allow to set order field for column #21

Closed PetrDlouhy closed 3 years ago

PetrDlouhy commented 3 years ago

This PR allows to set sorting by different column, than the 'name' column. I made this partially because I misunderstood how make custom content in the columns - i expected similar behavior to Django ModeAdmin, and I used @property methods on model and this (similarily to admin_order_field). I rewrote my code with customize_row, so I don't need it anymore.

But anyway, it might still be useful for somebody in some situations.

morlandi commented 3 years ago

Thank you @PetrDlouhy, I'll manage this together with Issue #20, soon ;)

The logic for customize_row has been inherited from the original app I started this project from: https://github.com/monnierj/django-datatables-server-side

I agree it's not the most natural solution for a Django app.

morlandi commented 3 years ago

Thank you @PetrDlouhy for your interesting contribution. Before publishing a new release, I'll try to extend it to cope with a sequence of fields to be used for column sorting, since I have a specific practical use case in mind for this

morlandi commented 3 years ago

@PetrDlouhy on second thought, I opted to publish a new release v4.1.7 with your PR, and write an issue #22 for allowing multiple sorting on each column.

The required modifications should be easy, but the project is rather limited in terms of unit tests, so I need to have some real data available for the specific use case to test them