vkaravir / bib-publication-list

Interactive publications lists with JavaScript + Bibtex
132 stars 63 forks source link

Feature Request: Passing additional options to underlying dataTables object #16

Closed anoroozian closed 8 years ago

anoroozian commented 8 years ago

I would like to pass on additional options to the underlying dataTables object, for example dynamically hide columns by making a call like this:

bibtexify("somefile.bib", "pubTable", {"columnDefs": [{"visible": false, "targets": [1]}]});

However the additional options are not passed on to the underlying dataTables object. See: https://github.com/vkaravir/bib-publication-list/blob/master/src/bib-publication-list.js#L259

Do you have any specific reasons for not passing any 'user-provided' options further down the call chain? It is possible to do something like this for example (assuming user_options holds my custom options):

var table = this.$pubTable.dataTable($.extend({}, { 'aaData': bibentries,
            'aaSorting': this.options.sorting,
            'aoColumns': [ { "sTitle": "Year" },
                { "sTitle": "Type", "sType": "type-sort", "asSorting": [ "desc", "asc" ] },
                { "sTitle": "Publication", "bSortable": false }],
            'bPaginate': false
        }, user_options));

Is this something that you could perhaps implement to increase the flexibility of your implementation?

wmayner commented 8 years ago

I'd like to sort by year and then month of publication. Not sure exactly how to do that, but this seems like it would help!

vkaravir commented 8 years ago

Apologies for the long silence. I just pushed a commit that adds this option. There already was a third optional argument upon initialization, and now you can add datatable there to pass options to datatable library.

For example, to change the sorting order:

bibtexify("#bibtex",
          "pubTable",
          { datatable: { aaSorting: [[0, "asc"], [1, "desc"]] } }
);
vkaravir commented 8 years ago

@wmayner: Unfortunately this does not help with sorting by month, as that information is not in the table currently.