Trunk JS Datatable Integration

I am building an application based mainly on Backbone JS and still impressive. Nevertheless, there is a part of the application that requires a rather flexible table / grid scheme, which would allow filtering / filtering / searching / columns on the client side, etc. ...

I have used Datatables in the past, and it seems like it would be great, but I am having some problems with the base models / collections in init.datatable.

One of the participants in the DT forums suggests using the mDataProp ( DataTable Forums ) attribute, but so far I have not been successful.

I was hoping someone could point me in the right direction so that I could use Datatables to browse my collections and items and still have access to all the great event links, etc. that Backbone offers.

Thanks!

+4
source share
1 answer

I don't know much about dataTable, but it looks like you can use the toJSON function in the Backbone collection for your aaData value.

Here is an example

 $('table').dataTable({ "aaData": yourCollection.toJSON(), "aoColumns": [ { "sTitle": "Engine", "mDataProp": "engine" }, { "sTitle": "Browser", "mDataProp": "browser" }, { "sTitle": "Platform", "mDataProp": "platform" }, { "sTitle": "Version", "mDataProp": "version" }, { "sTitle": "Grade", "mDataProp": "grade" } ] }); 
+3
source

Source: https://habr.com/ru/post/1388736/


All Articles