dynamcly loaded table from a js file.

dynamcly loaded table from a js file.

whitevampwhitevamp Posts: 6Questions: 0Answers: 0
edited March 2013 in General
Hello,
i have recently found this site, and i thought i would try this for sorting my table.
But i am having an issue with it, and now im pulling my hair out trying to figure it out.
the tables are not getting hooked / found.
i have tried
[code]
$(document).ready(function () {
$("#sortable_table").dataTable({
"sAjaxSource": "include/pagebuild2.js",
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"bJQueryUI": true
"sAjaxDataProp": "buildPlayerTable"
});
});
[/code]

and
[code]
$(document).ready(function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"sAjaxSource": "include/pagebuild2.js"
} );
} );
[/code]

and
[code]
// POST data to server
$(document).ready( function() {
$("#sortable_table").dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "include/pagebuild2.js",
"fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
oSettings.jqXHR = $.ajax( {
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
} );
} );
[/code]
to no avail.
what am i doing wrong?
OHH and here is this, from one of the tries.
http://debug.datatables.net/imegaf
and here is a sample of the java formed table output.
[code]



Player
Area
Job
Bazaar Message






Player
Area
Job
Bazaar Message



[/code]

Replies

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    > "bServerSide": true

    Have you fully implemented server-side processing, as described here: http://datatables.net/usage/server-side . Also it would be useful if you could link to your page.

    Allan
  • whitevampwhitevamp Posts: 6Questions: 0Answers: 0
    i have tried non server side as-well.
    also the way this is working is like this.
    a php file gets called from a js file, then that js file gets called from another ( php page. ( the roster.php page is the main page.))

    [code]Also it would be useful if you could link to your page.[/code]
    [code]
    http://sstestserver.zapto.org:22080/roster_sortable_test/roster.php
    [/code]
    this data only get's populated when there is a person logged into a game server, and as such i will leave my character logged into the game, for the rest of today.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    [code]
    Line 24 - SyntaxError: Expected token '}'
    [/code]

    That's not going to help :-). You are missing a comma.

    Allan
  • whitevampwhitevamp Posts: 6Questions: 0Answers: 0
    [code]
    That's not going to help :-). You are missing a comma.

    [/code]
    ok fixed.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Can you add:

    [code]
    alert( $("#sortable_table").length );
    [/code]

    just before you initialise the DataTable please? I don't think it is in the document when initialised.

    Allan
  • whitevampwhitevamp Posts: 6Questions: 0Answers: 0
    edited March 2013
    [code]
    [quote]allan said: alert( $("#sortable_table").length );[/quote]
    [/code]
    done.
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Good.

    And as I am sure you can deduce from the result, there is no #sortable_table when you try to initialise it.
  • whitevampwhitevamp Posts: 6Questions: 0Answers: 0
    [quote]allan said: And as I am sure you can deduce from the result, there is no #sortable_table when you try to initialise it. [/quote]
    yeap and this has been the issue with other sort-table progs i have tried.
    and i cant figure out what is going on, the table is set up properly, and its loading, but any time i try to add a prog to sort that table it cant find it.
    any ideas on what i need to do to get it to find the table?
  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin
    Its not a problem with the table libraries - the problem is your loading order.

    You are currently doing:

    1. Try to initialise table
    2. Insert table into document

    No table library is going to initialise a table which isn't there!

    So you need to sort out the order of your code on the page. My guess is that `loadStartPage` is putting the table into the page? That is run at window.onload, which is after the DOM ready which you are using for the table init.

    Allan
  • whitevampwhitevamp Posts: 6Questions: 0Answers: 0
    ok thx, ill look into seeeing what i can come up with.
    and thx allen for the help with this.
This discussion has been closed.