How to use DataTables in MediaWiki 1.34
How to use DataTables in MediaWiki 1.34

Hi,
I need help with using Datatables in Mediawiki.
I have inserted the below code in the LocalSettings.php file
$wgResourceModules['DataTables'] = array(
'scripts' => array( '/extensions/DataTables/media/js/jquery.js','/extensions/DataTables/media/js/jquery.dataTables.min.js'),
'styles' => array( '/extensions/DataTables/media/css/jquery.dataTables.min.css'),
// could e.g. add dependencies on core modules here
);
// ...and set up a hook to add it to every page
function addDataTablesScript( &$out ) {
$out->addModules( 'DataTables' );
return true;
}
$wgHooks['BeforePageDisplay'][] = 'addDataTablesScript';
and In common.js file
$( document ).ready(function() {
$('.wikitable').DataTable();
});
Its throwing below error in console..
Uncaught TypeError: Cannot read property 'mData' of undefined
I have searched about this error, it saying it occured because of missing thead tag.
But in wikieditor there is option to insert <thead> tag, Tried with raw html table also, its not working.
Please help me on this, If anyone know how resolve this issue..
Thanks,
Vikas
Answers
I don't know anything about MediaWiki, but you would get that error if the size of the table is wrong - say if the number of columns in the header is different to the body/footer/data. This example here demonstrates that - note there is one less column in the header.
So, the first step would be to make sure the columns match up everywhere,
Colin