How to know if DataTable is using serverside or client data?

How to know if DataTable is using serverside or client data?

mxaaronmxaaron Posts: 2Questions: 2Answers: 0

I've initialized a data table by two ways:

CLIENT TABLE:

  self.outputTable = components.tables.adhocValidationOutputTable.DataTable({
                info: true,
                searching: false,
                responsive: true,
                data: data,
                bServerSide: false,
                sPaginationType: "full_numbers",
                columns: [
                    { title: "Issue Type", data: "issueType" },
                    { title: "File", data: "file" },
                    { title: "Line", data: "lineNumber" },
                    { title: "Rule", data: "rule" },
                    { title: "Message", data: "text"}
                ]
            });

SERVER SIDE TABLE:

 self.outputTable = components.tables.adhocValidationOutputTable.DataTable({
                info: true,
                searching: false,
                responsive: true,
                bProcessing: true,
                bServerSide: true,
                ajax: {
                    url: "/filevalidation/getPage/",
                    type: 'POST',
                    data: function (d) {
                        d.timestamp = self.timestamp;
                        d.customerCode = self.selectedTenantInDB();
                    }
                },
                deferLoading: 0,
                sPaginationType: "full_numbers",
                columns: [
                    { title: "Issue Type", data: "issueType" },
                    { title: "File", data: "file" },
                    { title: "Line", data: "lineNumber" },
                    { title: "Rule", data: "rule" },
                    { title: "Message", data: "text"}
                ]
            });

I've tried using self.outputTable.settings()[0].bServerSide to see if it's true or false but it comes up undefined for me, although other properties are there.

Is there something missing from my initialization?

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited November 2015

    I dont have a server side example to be able to debug, but there should definitely be something in the settings() output, I usually just output the settings to the console via console.log and poke through the data (Like so), it would definitely be in the oInit object, but there should also be a server side object, probably called oServerSide. I use the ajax mostly, and theres an ajax object.

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin

    You need to know this on the client-side at run time? If so use the page.info() method which has a serverSide property that will be true if the table is server-side processing. Never use the settings object is you can possibly avoid it. The properties in it can, will and do change between versions - it is a private API.

    If you are simply curious about a table you can run the debugger on the table. It will tell you how the table is set up and what the data source is.

    Allan

This discussion has been closed.