Search
898 results 41-50
Manual
- Ordering plug-in development › Publish your plug-inIf you create an ordering plug-in for DataTables, please let us know!. Others will likely benefit for your plug-in and I (and the community as a whole) will be very grateful for your contribution.
- Plug-in developmentAs flexible as DataTables is, there may be times when you wish to customise certain aspects to your specific needs. DataTables has a number of plug-in and extension options which are detailed in this section. If you do take the time to create a plug-in for DataTables and wish to share it with others, please get in touch.
- Feature plug-in development › Publish your plug-insIf you create a feature plug-in for DataTables, please let us know! Others may benefit from your plug-in and I (and the community as a whole) will be very grateful for your contribution.
- API plug-in development › Examples › rows().addClass()This example is more complex as we need to take in to account the multi-table nature of the API. What needs to happen is that we loop over each context in the API (i.e. each table) and for each also loop over the rows in that table and add the class where required. This is the code in the fullest form: DataTable.Api.register( 'rows().addClass()', function ( klass ) { var context = this.context; for ( var i=0, ien=this.length ; i<ien ; i++ ) { var innerApi = new DataTable.Api( context[i] ); for ( var j=0, jen=this[i].length ; j<jen ; j++ ) { var node = innerApi.row( this[i][j] ).node(); $(node).addClass( klass ); } } return this; } ); Note that rows() will populate the result set with an array of arrays! One inner array for each table and each inner array contains the indexes for that table. In the code above, this means that this.context.length === this.length (i.e. there is one item in the result set for each table). As looping over multiple tables in this form is common in the API, DataTables provides an iterator method to simplify it. iterator will handle the double for loop internally (and number of other loop types) and provide information about the loop to a closure function. The above code can thus be simplified to be: DataTable.Api.register( 'rows().addClass()', function ( klass ) { return this.iterator( 'row', function ( context, index ) { var node = new DataTable.Api( context ).row( index ).node(); $(node).addClass( klass ); } ); } ); As of DataTables 1.10.3 this can be simplified further as the callback methods for iterator are executed in the scope of an API instance that contains only the table in question in its context: DataTable.Api.register( 'rows().addClass()', function ( klass ) { return this.iterator( 'row', function ( context, index ) { var node = this.row( index ).node(); $(node).addClass( klass ); } ); } );
Reference
responsive.details.type
› Set the child row display control typean extension to the default set of DataTables options.responsive.details.target
› Column / selector for child row display control when using `column` details typean extension to the default set of DataTables options.buttons.buttons.destroy
› Function that is called when the button is destroyedbuttons.buttons.destroy
› Function that is called when the button is destroyedThis function is provided to allow button authors to be able to assign custom events to the host DataTable or the button's DOM node, and then cleanly remove those events when a button is destroyed, ensuring that there are no memory leaks. Of particular interest when using this method and the buttons.buttons.init option to attach events, will be the buttons.buttons.namespace option (accessible as the namespace parameter of the third parameter passed into this function). The namespace option is a unique namespacing string for every button, allowing events to be correctly removed without accidentally also removing other events.