Not able to do ajax.url().load() on multiple Tables

Not able to do ajax.url().load() on multiple Tables

lokomolokomo Posts: 8Questions: 0Answers: 0
edited March 2014 in DataTables 1.10
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.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Your code looks fine there as far as I can see. It might be a problem with 1.10 - can you link me to a test case showing the problem so I can investigate and fix if appropriate.

    Thanks,
    Allan
  • lokomolokomo Posts: 8Questions: 0Answers: 0
    Hi allan,

    thanks a lot for the quick response. I put up an example here:
    http://gazeto.de/wp-content/tmp/datatables/
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    That's awesome thanks. Very certainly looks like a bug to me. I'll check into it and get back to you shortly.

    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Fixed here: https://github.com/DataTables/DataTablesSrc/commit/caffdb49e . I'm just rebuilding the repo and the nightly :-)

    Thanks for bringing this up and the test case!

    Allan
  • lokomolokomo Posts: 8Questions: 0Answers: 0
    Wow, that was quick. Thanks a lot! It works like a charm now ;-)
  • xamelleohxamelleoh Posts: 1Questions: 0Answers: 0
    Hello,

    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
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I don't see how that is the same issue at all - however, I do see the problem. I'm just not sure what is causing it. I would say that if you want to send extra data you would be better off using fnServerParams has you have for other variables, but this looks like it might be jQuery related. Passing a url with GET and then adding extra data for a jsonp request...

    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
  • boyceeboycee Posts: 1Questions: 0Answers: 0
    Argh!

    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! :-)
This discussion has been closed.