Reload table with data from input boxes

Reload table with data from input boxes

BCKurtBCKurt Posts: 5Questions: 0Answers: 0
edited December 2010 in General
I'm using jQueryUI to add sliders to the main page. I wanted the user to be able to slide the bars to select a proper range and then reload the table, passing those variables to the server-side source.

I am using "sAjaxSource": "myPHPFile.php" but I don't know how to get my own Javascript function reload the data. I'm not sure what to search for or if it's even possible. I've looked at fnReloadAjax, but that seems like the wrong way to go, since I didn't see anything about passing variables.

Thanks.

Replies

  • BCKurtBCKurt Posts: 5Questions: 0Answers: 0
    edited December 2010
    [code]
    var oTable;
    $(document).ready(function() {
    oTable = $('#example').dataTable( {
    "sDom": 'T<"clear">lfrtip',
    "bAutoWidth": false,
    "aoColumns": [
    {"sWidth": "10%"},
    {"sWidth": "30%"},
    {"sWidth": "25%"},
    {"sWidth": "5%"},
    {"sWidth": "5%"},
    {"sWidth": "5%"},
    {"sWidth": "5%"},
    {"sWidth": "10%"},
    {"sWidth": "5%"},
    {"sWidth": "5%"}
    ],
    "iDisplayLength": 25,
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "schoolActivityGenerator.php",
    "fnServerData": function (sSource, aoData, fnCallback) {
    aoData.push({"name": "usage", "value": $("#usage").val()});
    aoData.push({ "name": "licenses", "value": $("#licenses").val()});
    $.getJSON(sSource, aoData, function(json) {
    fnCallback(json)
    });
    }
    } );
    $("#button").click(function() {
    oTable.fnDraw();
    });
    } );
    [/code]

    Nothing happens when I click the button, but if I add bServerSide: true, it seems to work, but the table is broken. The pagination doesn't work. The result number displays NaN. Sorting doesn't work. I'm not sure why, but without bServerSide, it works fine (minus the button).

    Edit: The DB is MS SQL, so the LIMIT doesn't work, which is why I cannot use bServerSide. I never looked for an alternative to LIMIT for MS SQL, so I guess I'll have to.
  • BCKurtBCKurt Posts: 5Questions: 0Answers: 0
    Think I figured it out. I found an alternative to LIMIT for MS SQL (using ROW_NUMBER()) and altered my code to use the passed variables.
This discussion has been closed.