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

(WIP) allow to set detail callback (i.e. to display it in modal) #24

Closed PetrDlouhy closed 3 years ago

PetrDlouhy commented 3 years ago

This is conceptual code, that allowed me to use Bootstrap 3 modals for table details with simple settings:

                    detail_callback: function(data, tr){
                       $('.modal-body').html(data, 'details');
                       $('.modal').modal();
                    },

I am not sure how general the implementation of this should be, so I am leaving that for further discussion. I can implement it to be quite concrete with just modal class to be set, or even more code could be leaved for users to implement.

morlandi commented 3 years ago

Nice and useful addition, thank you @PetrDlouhy I'll manage this PR soon (hopefully).

A few notes:

morlandi commented 3 years ago

Also, would be nice to add support for redrawing a single row of the table, and maybe enhance it at will. So after closing the modal the edited record could be up to date without losing page selection, etc etc ...

morlandi commented 3 years ago

@PetrDlouhy thanks for contribution; I merged your PR, but also did a little cleanup to remove some code duplication:

https://github.com/morlandi/django-ajax-datatable/commit/5d05db2e5e488d7f9c8d7585668708f5e5678b8d