DataTables 1.10 AjaxSource and fnServerData

DataTables 1.10 AjaxSource and fnServerData

Godrules500Godrules500 Posts: 25Questions: 13Answers: 0

In Datatables 1.10, is sAjaxSource still applicable or has it been replaced? If it has been replaced, how can I convert my setup to use the new and better 1.10 way?

Is there anything else in there that needs to be replaced with 1.10? Been looking, but I'm just not sure.

Also, I need to a way to catch the ajax data that is sent back up 1 time so that I can set a global variable. Is there a way to do this? I noticed that the documents say not to replace fnCallback, but I still need a way to have a done or another success.

tblShowRMasterList = $('#tblShowRMasterList').DataTable({
            "scrollY": "auto",
            "scrollX": "100%",
            "scrollCollapse": true,
            "bSort": false,
            "bFilter":false,
            "bPaginate": false,
            "bAutoWidth": true,
            "serverSide": true,
            "processing": false,
            "destroy": true,
            "sAjaxSource": {
                "url": "@Url.Action("DisplayRERMasters", "Receipts")",
                "type": "POST",
            },
            "fnServerData": function (sSource, aoData, fnCallback)
            {
                var oModel = new Object()
                $(aoData).each(function (index, value)
                {
                    if (value.name == "sEcho")
                    {
                        oModel.sEcho = value.value
                    }
                    else if (value.name == "sColumns")
                    {
                        oModel.sColumns = value.value;
                    }
                    else if (value.name == "iColumns")
                    {
                        oModel.iColumns = value.value;
                    }
                    else if (value.name == "iDisplayStart")
                    {
                        oModel.iDisplayStart = value.value;
                    }
                    else if (value.name == "sSearch")
                    {
                        oModel.sSearch = value.value;
                    }
                    else if (value.name == "iSortingCols")
                    {
                        oModel.iSortingCols = value.value;
                    }
                    else if (value.name == "iDisplayLength")
                    {
                        oModel.iDisplayLength = value.value;
                    }
                });

                $.ajax({
                    "type": "POST",
                    "url": sSource.url,
                    "data": JSON.stringify({ param: oModel, liReceiptChildren:g_oReceipt.liReceiptChildren}),
                    "success": fnCallback
                });

            },

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    There is a link to this conversion guide right above your post:
    http://datatables.net/upgrade/1.10-convert

  • Godrules500Godrules500 Posts: 25Questions: 13Answers: 0

    Maybe it's because I don't understand it well enough, but that doesn't help me much because I don't know how to get the iStartingPosition and those attributes to the controller.

    It doesn't seem to me that DataTables doesn't have any examples similar to how I do it.

This discussion has been closed.