Creating HTML links to automatically filter table data
Creating HTML links to automatically filter table data
jogilliver
Posts: 2Questions: 0Answers: 0
Hi,
I'm quite new to Javascript, so forgive me if this is a simple question.
I've got DataTables working on my site nicely but I want to set up a menu of HTML links to automatically filter the table data, e.g. one link would show rows that reference 'apples', another would show rows that reference 'oranges', etc.
This is how I'm initialising my table:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"iDisplayLength": 10,
"aLengthMenu": [[10, 20, -1], [10, 20, "All"]],
"aoColumnsDef": [
{ "sType": 'date-uk', "aTargets": [ 3 ] }
],
});
} );
[/code]
And this is how I'm linking to the filtered data:
[code]
[/code]
The table is initialising fine but no matter what I do, I get an Uncaught ReferenceError that oTable is not defined when I click the link.
Any advice would be -greatly- appreciated.
Jo.
I'm quite new to Javascript, so forgive me if this is a simple question.
I've got DataTables working on my site nicely but I want to set up a menu of HTML links to automatically filter the table data, e.g. one link would show rows that reference 'apples', another would show rows that reference 'oranges', etc.
This is how I'm initialising my table:
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"iDisplayLength": 10,
"aLengthMenu": [[10, 20, -1], [10, 20, "All"]],
"aoColumnsDef": [
{ "sType": 'date-uk', "aTargets": [ 3 ] }
],
});
} );
[/code]
And this is how I'm linking to the filtered data:
[code]
[/code]
The table is initialising fine but no matter what I do, I get an Uncaught ReferenceError that oTable is not defined when I click the link.
Any advice would be -greatly- appreciated.
Jo.
This discussion has been closed.
Replies
However, I would strongly encourage you to use a jQuery click event rather than DOM0 events to attach a listener and fire it.
Allan
Jo