_fnFeatureHtmlTable fails with booble scrollX option
_fnFeatureHtmlTable fails with booble scrollX option
limplash
Posts: 3Questions: 1Answers: 0
According to the documentation the scrollX option has boolean value of true or false but the size function with in the _fnFeatureHtmlTable uses the _fnStringToCss function which doesn't take care of boolean parameters Hence if i use the scrollX options the datatable fails to init
This discussion has been closed.
Answers
Works well in this example. Are you using 1.10 or newer? If so, then please link to a test case.
Allan
Dear Allan
I'm using the latest version (1.10.9) and I am using bootstrap render, (js fiddle
https://jsfiddle.net/3w840zb4/) and i made one change to my dataTables.bootstrap.js at the start to include scrollX option by default i.e.,
$.extend( true, DataTable.defaults, {
dom:
"<'row'<'col-sm-6'l><'col-sm-6'f>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
renderer: 'bootstrap',
scrollX: true
} );
I get an error "datatables.js:4473 Uncaught TypeError: s.match is not a function" which is the last line in _fnStringToCss which is
function _fnStringToCss( s )
{
if ( s === null ) {
return '0px';
}
the function calling _fnStringToCss with boolean as "s" is an internal function in the _fnFeatureHtmlTable called size which is
var size = function ( s ) {
return !s ? null : _fnStringToCss( s );
};
and then with in the same _fnFeatureHtmlTable function we have the lines
var scroller = $( _div, { 'class': classes.sScrollWrapper } )
.append(
$(_div, { 'class': classes.sScrollHead } )
.css( {
overflow: 'hidden',
position: 'relative',
border: 0,
width: scrollX ? size(scrollX) : '100%'
} )
now where we set the width we are using the scrollX option and if true size gets called with a boolean value and the _fnStringToCss gets called with a boolean value which don't have the match function.
I hope i was able to make it clear also i am linking a jsfiddle
https://jsfiddle.net/3w840zb4/
you can see the result also if you change the scrollX option in the start to false it starts to work
Kind regards
Hi,
Thanks for posting this. This error has actually been fixed already in the 1.10.10-dev version which you can try out from the nightly's. I expect to release 1.10.10 later today.
With the nightly: https://jsfiddle.net/3w840zb4/1/
Allan
Dear Allan
Thank you for your support, Excellent work with the plugin