Pegase745 / sqlalchemy-datatables

SQLAlchemy integration of jQuery DataTables >= 1.10.x (Pyramid and Flask examples)
MIT License
159 stars 67 forks source link

Datatable crud operations #89

Closed saifraider closed 7 years ago

saifraider commented 7 years ago

My Datatable has 4 columns. id, name, email, edit/delete.

On server side, I have defined my columns as (User is my model) columns = [ ColumnDT(User.id), ColumnDT(User.username), ColumnDT(User.email) ] query = User.query.with_entities(User.id, User.username, User.email) params = request.args.to_dict() rowTable = DataTables(params, query, columns) return jsonify(rowTable.output_result())

returned data contains only 3 columns but my datatable has 4 columns. So I am getting an error. What should I do?

Pegase745 commented 7 years ago

@saifraider I've just added a very quick example in order to do that in a1068c2. Hope it helps !

saifraider commented 7 years ago

Thank you so much. It would be nice if you can provide flask example

Pegase745 commented 7 years ago

what matters here is this javascript code

"columnDefs": [ {
    "targets": -1,
    "data": null,
    "defaultContent": "<a href='' class='edit'>Edit</a> / <a href='' class='delete'>Delete</a>"
} ]

The use of Flask or Pyramid isn't related to your problem.

Pegase745 commented 7 years ago

source: https://datatables.net/examples/ajax/null_data_source.html