Problem accessing table from outside element
Problem accessing table from outside element
Hi,
I'm having a problem with filtering a datatables table based on date from outside. I've got a jquery datepicker object, and I want to filter a table on a single column so that it only shows items that have that date. I'm running into a problem, after changing the date I get the error:
Error: oTable is undefined
The code I'm using is this:
[code]
$(document).ready(function() {
/* Init DataTables */
var oTable = $('#example').dataTable();
/* Apply the jEditable handlers to the table */
$('td:eq(4), td:eq(5),td:eq(6)', oTable.fnGetNodes()).editable( 'editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "14px"
} );
} );
$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker" ).datepicker("option", "dateFormat","dd/mm/yy");
$( "#datepicker" ).datepicker().change(function() {
oTable.fnFilter( $(this).val() , 6);
});
});
[/code]
I'm basicly trying to update the table whenever the datepicker element is changed, but am really confused about how to filter the table. Any help would really be appreciated
Thanks
I'm having a problem with filtering a datatables table based on date from outside. I've got a jquery datepicker object, and I want to filter a table on a single column so that it only shows items that have that date. I'm running into a problem, after changing the date I get the error:
Error: oTable is undefined
The code I'm using is this:
[code]
$(document).ready(function() {
/* Init DataTables */
var oTable = $('#example').dataTable();
/* Apply the jEditable handlers to the table */
$('td:eq(4), td:eq(5),td:eq(6)', oTable.fnGetNodes()).editable( 'editable_ajax.php', {
"callback": function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
"submitdata": function ( value, settings ) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition( this )[2]
};
},
"height": "14px"
} );
} );
$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker" ).datepicker("option", "dateFormat","dd/mm/yy");
$( "#datepicker" ).datepicker().change(function() {
oTable.fnFilter( $(this).val() , 6);
});
});
[/code]
I'm basicly trying to update the table whenever the datepicker element is changed, but am really confused about how to filter the table. Any help would really be appreciated
Thanks
This discussion has been closed.
Replies