giterlizzi / dokuwiki-plugin-datatables

Add DataTables support to DokuWiki
GNU General Public License v2.0
10 stars 11 forks source link

Default column sorting option syntax not obvious #7

Closed stevenj closed 8 years ago

stevenj commented 9 years ago

I tried to sort a table, by default on the second column, and not the first.

<datatables order="[[1, 'asc']]" >

resulted in the datatables elements disappearing from the page. I couldn't work out any syntax which would allow the order option to be set. I am not sure if this is a bug, or just my misunderstanding of the syntax to pass the option.

<datatables order="[]" > 

Doesn't break the table, but also doesn't do achieve the desired outcome.

ghybs commented 8 years ago

Hi,

Indeed it looks like this option is quite special in that it requires an object (nested arrays) to be specified in the tag attribute.

Therefore it requires 2 tweaks:

I will propose a PR to address it, hopefully it should be accepted.

Otherwise, you can simply edit the syntax.php file of DataTables plugin, and replace line 57:

$html5_data[] = sprintf('data-%s="%s"', $key, (string) $value);

by:

$html5_data[] = sprintf("data-%s='%s'", $key, str_replace("'", "&apos;", (string) $value));
ghybs commented 8 years ago

Hi again,

The plugin is now merged with pull request #9, so it should work by simply updating it through DokuWiki. Thanks to @LotarProject for having accepted the PR.

Please make sure to use the syntax above.

Hope this helps.