How to know if DataTable is using serverside or client data?
How to know if DataTable is using serverside or client data?
mxaaron
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?
This discussion has been closed.
Answers
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 viaconsole.log
and poke through the data (Like so), it would definitely be in theoInit
object, but there should also be a server side object, probably calledoServerSide
. I use theajax
mostly, and theres an ajax object.You need to know this on the client-side at run time? If so use the
page.info()
method which has aserverSide
property that will betrue
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