Get current dataTables
Get current dataTables
Hi,
i use a javascript class, each object can create a datatables (each viewing a different SQL table).
how can i retrieve the current datatables when i select a row ?
i mean :
[code]
...
,"oTableTools": {
"sRowSelect": "single"
,"aButtons": [ ]
,"fnRowSelected": function(node) {
alert("select id="+node[0].id); // ok, i get the right id
}
}
...
[/code]
where can i store this id ?
"this" isn't the datatables, oTable isn't usable.
i mean something like "context" when using $.ajax()/
i use a javascript class, each object can create a datatables (each viewing a different SQL table).
how can i retrieve the current datatables when i select a row ?
i mean :
[code]
...
,"oTableTools": {
"sRowSelect": "single"
,"aButtons": [ ]
,"fnRowSelected": function(node) {
alert("select id="+node[0].id); // ok, i get the right id
}
}
...
[/code]
where can i store this id ?
"this" isn't the datatables, oTable isn't usable.
i mean something like "context" when using $.ajax()/
This discussion has been closed.
Replies
Allan
i must explain more :
i have severals objects from same class.
each object creates a datatable, using a unique name "dt_name"
[code]
MyObject.prototype= {
...
dt_create: function() {
$('body').append("...");
this.oTable= $('#' + this.dt_name).datatables({
....
"oTableTools": {
...
"fnRowSelected": function(node) {
// current node id is "node[0].id"
// how to store this id in "this.current_id" or call this.setCurrentId()
}
}
});
}
}
[/code]
it's only a scope problem, i resolve it with such a (dirty) code :
[code]
...
var that= this;
dt_create: function() {
$('body').append("...");
this.oTable= $('#' + this.dt_name).datatables({
....
"oTableTools": {
...
"fnRowSelected": function(node) {
that.current_id= node[0].id;
}
}
});
[/code]
of course !
may be i can use $.proxy() too...