Extension talk:DataTables
This page used the LiquidThreads extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
How to use the ResourceLoader ?
How to i load the script using ResourceLoader ? I'm using Mediawiki ver 1.21.1 Rabin .Y (talk) 10:17, 30 July 2013 (UTC)
- Hi Rabin,
- From within an extension you should add
ext.datatables
as a dependency to your ResourceLoader module (if you have one.) If you don't I suggest defining a new ResourceLoader module that will contain some JavaScript/CSS for your extension. It might look like this: $wgResourceModules['ext.myExtension'] = array( 'scripts' => 'js/ext.myExtension.js', 'styles' => 'css/ext.myExtension.css', 'messages' => array( 'myextension-hello-world', 'myextension-goodbye-world' ), 'dependencies' => array( 'jquery.ui.datepicker', 'ext.datatables' ), 'localBasePath' => __DIR__, 'remoteExtPath' => 'MyExtension' );
- Once this is done, you can use the DataTables.net jQuery library as normal. In your JavaScript code, you can
$(document).ready(function() { // Add the default datatables markup $( '#example' ).dataTable(); // Do more fancy things (like the examples on DataTables.net) $('#example').dataTable( { "bPaginate": false, "bLengthChange": false, "bFilter": true, "bSort": false, "bInfo": false, "bAutoWidth": false } ); } );
- I strongly suggest reading the DataTables.net documentation on http://datatables.net/.
- If you would like to call DataTables from within a page, this is a little more involved. Since MediaWiki does not allow JavaScript within pages (for security reasons among other things,) you might want to look at Extension:Javascript. Calling DataTables from within a page would look something like this:
- [[daniel renfro]] talk/email 14:52, 1 August 2013 (UTC)
<javascript> $(document).ready(function() { mw.loader.using( 'ext.datatables', function() { // Now you use datatables like above. }); }); </javascript>
- Thank you for your quick reply,
- I'm not much of a extensions developer, I use my wiki to document my work, and I like to use the DataTable extension when needed for pages with big tables.
- from your above replay, i now understand that this extensions is more of "library" for other extensions what would like to use the DataTable plugin ?
- Is there a way to set it in the core of wikimedia and not by specific extensions - like in the LocalSettings file ? Rabin .Y (talk) 10:43, 4 August 2013 (UTC)
- Thank you for your quick reply,
Disable first column per default?
I am calling a datatable by #asking data from a certain category. This is a category that only contains pictures.
{{#ask: [[Category:Archive Photo]]
|?Category=Categories
|format=datatables
}}
I would like to have a result table with one column showing the thumbnail pics and another column showing the categories the pics are connected with.
However, no matter what I do there are always 2 columns showing the pic.
If I go to the control panel I can deactivate the first column ("#") and the result is as I would like to see it.
Is there a way to disable the first column ("#") by default?
Or do I have to define the #ask query in a different way?
Thank you! 93.193.58.43 (talk) 20:35, 21 July 2017 (UTC)