Server side processing question

Server side processing question

jchappell99jchappell99 Posts: 15Questions: 0Answers: 0
edited January 2014 in General
Evening. Very new to datatables. I have it working by calling a .net web service returning jSon. I want only my first call to go to the server. I'm returning all the records to the client from the first call. When I set server side to true, it calls every time back to the WS. When I set it to false, it is calling the WS on page load and I want it only called when the filter button is clicked. Is this possible to not have the datatable loaded until after button is clicked and still have server side = false?

I don't have code to snare as I'm on my iPad and code is at work. I can post tomorrow if needed

Any help is appreciated

Thanks
John

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > Is this possible to not have the datatable loaded until after button is clicked and still have server side = false?

    Sure - just initialise the DataTable in your `click` event handler :-). It doesn't need to be initialised on page load.

    Allan
  • jchappell99jchappell99 Posts: 15Questions: 0Answers: 0
    $(document).ready(function () {
    $("#get").click(getUserNames());
    });

    var getUserNames = function () {
    $("#retiredTable").dataTable({
    "oLanguage": {
    "sZeroRecords": "No records to display",
    "sSearch": "Grid Search"
    },
    "aLengthMenu": [[25, 50, 100, 150, 250,-1], [25, 50, 100, 150, 200, "All"]],
    "iDisplayLength": 25,
    "bSortClasses": false,
    "bStateSave": false,
    "bPaginate": true,
    "bAutoWidth": false,
    "bProcessing": true,
    "bServerSide": false,
    "bDestroy": false,
    "sAjaxSource": "GetData.asmx/GetRetiredData",
    "bJQueryUI": true,
    //"sPaginationType": "full_numbers",
    "bDeferRender": true,
    "fnServerParams": function (aoData) {

    aoData.push({ "name": "iParticipant", "value": $("#participant").val() });

    },
    "fnServerData": function (sSource, aoData, fnCallback) {
    $.ajax({
    "dataType": 'json',
    "contentType": "application/json; charset=utf-8",
    "type": "GET",
    "url": sSource,
    "data": aoData,
    "success":
    function (msg) {

    var json = jQuery.parseJSON(msg.d);
    fnCallback(json);
    $("#retiredTable").show();
    }
    });
    }
    });
  • jchappell99jchappell99 Posts: 15Questions: 0Answers: 0
    Code is above. Population is done via the click event but when server side is set to "False", it's firing on load.
This discussion has been closed.