Possible bug when using defaults?

Possible bug when using defaults?

mihomesmihomes Posts: 165Questions: 23Answers: 0
edited March 2014 in DataTables 1.10
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 :

[code]
$.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": "No data available.",
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
"infoEmpty": "Showing 0 to 0 of 0 entries",
"infoFiltered": "(filtered from _MAX_ total entries)",
"processing": '  Please wait...'
},
"lengthMenu": [
[10, 25, 50, 100, 250, -1],
[10+' rows', 25+' rows', 50+' rows', 100+' rows', 250+' rows', "Show All"] // change per page values here
]
} );
[/code]

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

[code]
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,
.............

[/code]

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 :

[code]
$.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": "No data available.",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total entries)",
"sProcessing": '  Please wait...'
},
"aLengthMenu": [
[10, 25, 50, 100, 250, -1],
[10+' rows', 25+' rows', 50+' rows', 100+' rows', 250+' rows', "Show All"] // change per page values here
]
} );
[/code]

... and this worked as expected.

Replies

  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    edited March 2014
    > What I expected was the defaults to be loaded then my own options take precedence over those defaults.

    That is exactly what should happen. Can you link me to the page showing the error so I can investigate please?

    This should be true if you run it on your console: `$.fn.dataTable.defaults === $.fn.DataTable.defaults`

    Allan
  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    edited March 2014
    [code]$.fn.dataTable.defaults === $.fn.DataTable.defaults [/code] does return true in the console.

    Unfortunately I can't link to the page as it is in development (domain pw'ed) and it is part of a user login (I would need to setup a user account with examples from the db) for you. Any other ideas or could I send you some files in some way?

    Not sure if this will help or not, but here is a debug when it happens - http://debug.datatables.net/aqeser - although I did not see the $.extend from dataTables.bootstrap.js listed.
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    edited April 2014
    Yup - bug. Did some digging and committed a fix here: https://github.com/DataTables/DataTablesSrc/commit/45da091f . The nightly is up to date with this fix now. *edit* Still rebuilding actually - few minutes and it will be...

    Allan
  • PaulMPaulM Posts: 2Questions: 0Answers: 0
    And here's my unfortunately semi-useless comment with no supporting example (as I've just worked around this problem and gone to bed):

    This fix appears to completely break table rendering for me.

    I'll check back tomorrow after work and if you believe that your fix is good I will try to provide an example then.
  • allanallan Posts: 63,691Questions: 1Answers: 10,500 Site admin
    Yup - broke tables for me as well. Sorry about that! I've just committed a fix as soon as I realised what I'd done. Both should work correctly now.

    Allan
  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    Will check later today. Thanks in advance for the quick fix Allan! Always appreciated!
  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    Working on my end now... thanks again!
  • PaulMPaulM Posts: 2Questions: 0Answers: 0
    Sorry about the poor report. Just wanted to drop you a quick note that there was an issue.

    Thanks for the quick fix.

    I agree that it now Works For Me.
This discussion has been closed.