One of the good sides of Datatables.js how it implements on html-tables.
And any html-table in node can have this jquery add-on.
1. Does or will this module give this like functionality, maybe adding css class to html-tables or it will only work with views-tables?

1.1. And if the answer is "no" could i use your module for views-tables and in parallel use datatables.js for html-tables?

2. Will this module use datatables.js only on client-side or server-side or both.

thx for the answers.

Comments

duellj’s picture

1. There is functionality to output tables as DataTables, using similar format to theme a table:


theme('datatable', $header, $rows, $attributes, $caption);

There's no documentation in the module on how to correctly format the input to this theme, but it's coming soon (working on it). To include this in a node, you would need php filter access. If there is interest, I could work on creating a datatable macro.

2. Not sure what you mean by this question. datatables.js will behave like any javascript file, on the client-side.

jonr’s picture

How do I enable this? Do I edit the template file? Can I hook it to a table id?

duellj’s picture

Status: Active » Closed (fixed)

How do I enable this? Do I edit the template file? Can I hook it to a table id?

Currently the main purpose of this module is to provide a views style plugin to output a view as a DataTable. If you're interested in hooking it into an existing tables, check out the examples at http://www.datatables.net/examples/

giorgio79’s picture

Status: Closed (fixed) » Active

Hello duellj,

You mentioned you are working on documenting the theme function call.
Is this still on the table?

I would like to put input fields in the table columns, and use datatables for their arrangement. Currently I am putting them in regular html tables like here http://drupal.org/node/80270

Datatables would be fantastic for that.

giorgio79’s picture

Status: Active » Fixed

Actually this stuff is way simple. :)

It can be used for any HTML table on the page :D

http://datatables.net/examples/basic_init/zero_config.html

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

zirvap’s picture

Status: Closed (fixed) » Active

Could someone describe in a bit more detail how to use this for non-views tables?

I've installed the module and verified that it works for views.

I then tried editing page.tpl.php, inserting

<script type="text/javascript">
$(document).ready(function() {
	$('#example').dataTable();
} );
</script>

in the header of the page, and using id="example" for my table, but with no visible results.

I've also tried looking at the source code for pages with views with data tables. I see the code for the data tables is included in entries like:
jQuery.extend(Drupal.settings, { ... "datatables": { "#datatable-1": ... } });

and have tried some copy-and-paste, but I find that flailing around at semi-random doesn't get me far enough :-(

zirvap’s picture

Status: Active » Fixed

I figured it out after a bit more flailing around.

In case others wonder:

When using this for non-views tables, I don't use this module. I just extract the library (from http://www.datatables.net/download/) in my sites/all/libraries. Then I edit page.tpl.php to put this in the header:

  <script type="text/javascript" language="javascript" src="sites/all/libraries/DataTables-1.8.2/media/js/jquery.js"></script>
  <script type="text/javascript" language="javascript" src="sites/all/libraries/DataTables-1.8.2/media/js/jquery.dataTables.js"></script>
  <script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
      $('#example').dataTable();
    } );
  </script>

...and then I give my table id="example"

(Maybe it can be done more elegantly, but this works for me :-)

zirvap’s picture

Status: Fixed » Active

Hm, weird. The recipie above only works if I have a datatable from views (using this module) on the same page (say, in a block).

So I'm opening this again, in case someone can help me out here.

duellj’s picture

Status: Active » Fixed

zirvap,

That's because the datatables library (collection of js and css) is only added during the view load, so you'll have to manually add the datatables library for your code to work:

drupal_add_library('datatables', 'datatables');

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.