Datatable buttons are not displaying in Reactjs application

Datatable buttons are not displaying in Reactjs application

manjuojalmanjuojal Posts: 1Questions: 1Answers: 0

In React Application, buttons are not displaying and getting error below(when i tried to add button)

utils.js:215 uncaught at handleFormTemplateChangeInternal TypeError: table.button is not a function
at TableGrid.componentDidMount (http://localhost:3000/0.chunk.js:2971:19)
at eval (webpack:///./~/react-dom/lib/ReactCompositeComponent.js?:265:25)
at measureLifeCyclePerf (webpack:///./~/react-dom/lib/ReactCompositeComponent.js?:75:12)
at eval (webpack:///./~/react-dom/lib/ReactCompositeComponent.js?:264:11)
at CallbackQueue.notifyAll (webpack:///./~/react-dom/lib/CallbackQueue.js?:76:22)
at ReactReconcileTransaction.close (webpack:///./~/react-dom/lib/ReactReconcileTransaction.js?:80:26)
at ReactReconcileTransaction.closeAll (webpack:///./~/react-dom/lib/Transaction.js?:206:25)
at ReactReconcileTransaction.perform (webpack:///./~/react-dom/lib/Transaction.js?:153:16)
at ReactUpdatesFlushTransaction.perform (webpack:///./~/react-dom/lib/Transaction.js?:140:20)
at ReactUpdatesFlushTransaction.perform (webpack:///./~/react-dom/lib/ReactUpdates.js?:89:32)

===========================

My code in componentDidMount is

var table = $('#myTable').DataTable();

table.button().add( 0, {
action: function ( e, dt, button, config ) {
dt.ajax.reload();
},
text: 'Reload table'
} );

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @manjuojal ,

    You would see those errors if the buttons extension weren't being loaded correctly. If you look at this page here, on the HTML and CSS tabs, you can see which files need to be included.

    Hope that helps,

    Cheers,

    Colin

This discussion has been closed.