Can an extension inject options to DataTables prior to initialization?

Can an extension inject options to DataTables prior to initialization?

JamaurJamaur Posts: 87Questions: 10Answers: 0
edited September 2015 in Free community support

Can an extension add/inject an extra option (Ex: columns.className) to datatables before initialization?

On preInit, I tried to add columns.className to settings.columnDefs, settings.aoColumnDefs & settings.aoColumns but all in vain.

I noticed that preInit is being fired after datatables has already cached or generated all nodes, thus not so preInit as the name suggests.

Is there supposed to be another event which fires before preInit so that extension authors can edit the options passed to datatables?

Thanks.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,727Questions: 1Answers: 10,506 Site admin
    Answer ✓

    Currently no as it isn't something I've required before. The preInit event will trigger after the table's basic initialisation has occurred, but before the data is read in and displayed.

    Perhaps there should be an initInit (urgh) event or similar...

    Allan

  • JamaurJamaur Posts: 87Questions: 10Answers: 0

    How about preOptions? Where the event is passed the DataTable's Options before it is processed...

  • allanallan Posts: 63,727Questions: 1Answers: 10,506 Site admin

    Yup - sounds sensible. {Link to your github discussion](https://github.com/DataTables/DataTables/issues/663) on this topic so we don't overlap.

    Allan

This discussion has been closed.