Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82440

Possible bug when using defaults?

$
0
0
I may have come across a bug or perhaps I am looking at this wrong. In the order of their loading :

jquery.dataTables.js - loads datatables

dataTables.bootstrap.js - I am extending some defaults with this for example :

$.extend( true, $.fn.DataTable.defaults, {
	"dom": "<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-md-12 col-sm-12 text-center'r>><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
	"pagingType": "bootstrap_full_number",
	"language": {
		"lengthMenu": "_MENU_ per page",
		"search": "Search: _INPUT_",
		"emptyTable": "<div class='margin-top-20 margin-bottom-20'><p><b>No data available.</b></p></div>",
		"info": "Showing <b>_START_</b> to <b>_END_</b> of <b>_TOTAL_</b> entries",
		"infoEmpty": "Showing <b>0</b> to <b>0</b> of <b>0</b> entries",
		"infoFiltered": "(filtered from <b>_MAX_</b> total entries)",
		"processing": '<div class="custom_loading box"><i class="fa fa-spinner fa-spin"></i> &nbsp;Please wait...</div>'
	},
    "lengthMenu": [
        [10, 25, 50, 100, 250, -1],
        [10+' rows', 25+' rows', 50+' rows', 100+' rows', 250+' rows', "Show All"] // change per page values here
    ]
} );

and finally I load my own options for the datatable in question in another js file such as :

		dt = $('#datatable').DataTable({
			"dom": "<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-md-12 col-sm-12 text-center'r>><'row'<'col-sm-12'<'#dtButtons'>>><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
			"language": {
				"emptyTable": "some custom message for this table"
			},
			"processing": true,
			"serverSide": true,
.............


What I expected was the defaults to be loaded then my own options take precedence over those defaults. Instead, only the head of the table shows and nothing else, but with zero errors showing in the console.

I later tried the 'old' format for my defaults :

$.extend( true, $.fn.dataTable.defaults, {
	"dom": "<'row'<'col-sm-6'l><'col-sm-6'f>><'row'<'col-md-12 col-sm-12 text-center'r>><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
	"pagingType": "bootstrap_full_number",
	"oLanguage": {
		"sLengthMenu": "_MENU_ per page",
		"sSearch": "Search: _INPUT_",
		"sEmptyTable": "<div class='margin-top-20 margin-bottom-20'><p><b>No data available.</b></p></div>",
		"sInfo": "Showing <b>_START_</b> to <b>_END_</b> of <b>_TOTAL_</b> entries",
		"sInfoEmpty": "Showing <b>0</b> to <b>0</b> of <b>0</b> entries",
		"sInfoFiltered": "(filtered from <b>_MAX_</b> total entries)",
		"sProcessing": '<div class="custom_loading box"><i class="fa fa-spinner fa-spin"></i> &nbsp;Please wait...</div>'
	},
    "aLengthMenu": [
        [10, 25, 50, 100, 250, -1],
        [10+' rows', 25+' rows', 50+' rows', 100+' rows', 250+' rows', "Show All"] // change per page values here
    ]
} );

... and this worked as expected.

Viewing all articles
Browse latest Browse all 82440

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>