Jump to content

Extension talk:DataTables

About this board

Disable first column per default?

1
93.193.58.43 (talkcontribs)

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!

Reply to "Disable first column per default?"

How to use the ResourceLoader ?

3
The IceMan (talkcontribs)

How to i load the script using ResourceLoader ? I'm using Mediawiki ver 1.21.1

DanielRenfro (talkcontribs)

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:

<javascript>
$(document).ready(function() {
  mw.loader.using( 'ext.datatables', function() {
    // Now you use datatables like above.
  });
});
</javascript>
The IceMan (talkcontribs)

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 ?

Reply to "How to use the ResourceLoader ?"
There are no older topics