django-datatable-view
django-datatable-view copied to clipboard
"DataTables warning: table id=DataTables_Table_0 - Ajax error" with XEditableColumns
Following the example given at: http://django-datatable-view.appspot.com/x-editable-columns/
I created the view:
class UserDatatableView(XEditableDatatableView, LegacyDatatableMixin):
model = User
template_name = 'user_list.html'
datatable_options = {
'columns': [
("Nombres", 'first_name', helpers.make_xeditable),
("Apellidos", 'last_name', helpers.make_xeditable),
("Nombre de usuario", 'username', helpers.make_xeditable),
("e-mail", 'email', helpers.make_xeditable),
("Doc ID", 'id_document', helpers.make_xeditable),
("Nacimiento", 'birth_date', helpers.make_xeditable),
("Direccion", 'address', helpers.make_xeditable),
("Telefono", 'phone_number', helpers.make_xeditable)
]
}
And the page javscript is:
<script type="text/javascript" src ="{% static 'js/datatableview.js'%}"></script>
<script language='javascript'>
//datatableview.auto_initialize = false;
$(function(){
var xeditable_options = {};
datatableview.initialize($('.datatable'), {
fnRowCallback: datatableview.make_xeditable(xeditable_options),
});
})
</script>
I used, LegacyDatatableMixin because XEditableDatatableView does not have the datatable_options attribute But, when loading the page it shows the above error.
+1
I think this will have to be revisited with the updated versions of the code. I'll leave the issue open but anything using the Legacy table mixins is highly suspect.
All of the 'modern' versions of the views are missing the datatable_options attribute because they want you to point it at a Datatable subclass, which looks a lot like a django ModelForm.
beautiful goodbye