Not able to do ajax.url().load() on multiple Tables
Not able to do ajax.url().load() on multiple Tables
lokomo
Posts: 8Questions: 0Answers: 0
Hi,
i have two of the awesome Datatables:
[code]
var table = $('#UserTable').DataTable( {
ajax: "/ajax/admin/getusertable/datatable",
"aoColumns": [
{ "mData": "username"},
{ "mData": "email"},
{ "mData": "state"},
{ "mData": "note"},
{ "mData": "created_at"},
{ "mData": "updated_at"},
]
} );
var historytable = $('#UserHistoryTable').DataTable( {
"aoColumns": [
{ "mData": "key"},
{ "mData": "old_value"},
{ "mData": "new_value"},
{ "mData": "user_id"},
{ "mData": "updated_at"}
]
} );
[/code]
This works fine. When i do some Updates, i want to reload the UserTable.
I do
[code]
table.ajax.reload();
[/code]
this also works fine. But then i want to load the "historytable" with a new Datasource
[code]
historytable.ajax.url( "/ajax/getusrhstry/" + id ).load();
[/code]
This results in error throwing [quote]"DataTables warning: table id=UserTable - Requested unknown parameter 'username' for row 0."[/quote]
and destroy my UserTable.
Seems like, it is trying to load the Data into the "UserTable" instead into the "UserHistoryTable" but i have no clue what is wrong with my code.
i have two of the awesome Datatables:
[code]
var table = $('#UserTable').DataTable( {
ajax: "/ajax/admin/getusertable/datatable",
"aoColumns": [
{ "mData": "username"},
{ "mData": "email"},
{ "mData": "state"},
{ "mData": "note"},
{ "mData": "created_at"},
{ "mData": "updated_at"},
]
} );
var historytable = $('#UserHistoryTable').DataTable( {
"aoColumns": [
{ "mData": "key"},
{ "mData": "old_value"},
{ "mData": "new_value"},
{ "mData": "user_id"},
{ "mData": "updated_at"}
]
} );
[/code]
This works fine. When i do some Updates, i want to reload the UserTable.
I do
[code]
table.ajax.reload();
[/code]
this also works fine. But then i want to load the "historytable" with a new Datasource
[code]
historytable.ajax.url( "/ajax/getusrhstry/" + id ).load();
[/code]
This results in error throwing [quote]"DataTables warning: table id=UserTable - Requested unknown parameter 'username' for row 0."[/quote]
and destroy my UserTable.
Seems like, it is trying to load the Data into the "UserTable" instead into the "UserHistoryTable" but i have no clue what is wrong with my code.
This discussion has been closed.
Replies
Thanks,
Allan
thanks a lot for the quick response. I put up an example here:
http://gazeto.de/wp-content/tmp/datatables/
Allan
Thanks for bringing this up and the test case!
Allan
Having same problem here: http://kronan.com.ua/SearchService/table.html
When type for example "kathe" in search field it should send request to server with "q" parameter which equal to "kathe". It worked for me on 1.9 version when I used fnReloadAjax.
Now I'm using 1.10 beta 3 and it looks like datatables remove q parameter from request.
Here is code
[code]
$('.table-search').keypress(function(e){
if (e.which == 13) {
var url = "http://54.206.12.66:8081/api/v1" + ($(this).val() == '' ? '' : '?q=' + $(this).val());
oTable.ajax.url( url ).load();
}
});
[/code]
Thanks in advance,
Andriy
Bit pushed for time at the moment here, but that's where I would suggest starting to look. If you have a poke around, let us know how you get on.
Allan
I was battling this for a couple of days, great that it's fixed, I thought I was going mad!
Good work on the speedy turn around!
Thank you! :-)