Using JQuery DataTables, can I pass a javascript array as a data source but still using server-side paging

Here is my code:

								window.InHousePropertiesListVar = $('#inhouseproperties').DataTable( {
									"searching": false,
									"processing": true,
									"serverSide": true,
									responsive: true,
									"ajax": window.AjaxListPreURL + "&source=1&" + $('#searchPropertiesForm').serialize(),
									"fnDrawCallback": function () {
									'oLanguage': { 'sEmptyTable': "No Properties Found Matching Your Criteria" }
									//"scrollY": "100%",
									//"dom": "frtiS",
									//"deferRender": true
								} );

Open in new window

I have multiple Data Tables and would like to only make one call..

I wanted to do something like this and process the 2 data sources on the client side

$output[a] = SSP::complex(....);
$output[b] = SSP::complex(....);

echo json_encode($output);

Open in new window

Please advise, thanks.
Who is Participating?
As I said, there are things for datatables, that can be done for some "Alternate" ways to set the "data" option, you might look at this example -

see the code line -
   "data": dataSet,

this uses an ARRAY , not an object for the "data" ,and requires the column "titles" to be set. But you can also do objects.

Can you see how you can get an array back from your server by your AJAX, and not use the datatable AJAX at all, and then set the table rows with Your Ajax return.
greetings  Mark, ,  I do not understand what you may mean by -
        "pass a javascript array as a data source but still using server-side paging",
the Jquery dataTable has a "paging" process already built in, you set up your FULL data rows in the AJAX sendback, and then have a ROW amount to display, and it pages the full ROWS to the amount set to display.

The ajax return for a datatable can be adjusted, but, each datatable AJAX is usually meant for just ONE table, and you say - "I have multiple Data Tables and would like to only make one call", it might be easiest to use the default datatable AJAX (one table per ajax), and do several different ajax address returns for each table.

and alternative is to do your own AJAX and have -
        $output[a] = SSP::complex(....);
        $output[c] = SSP::complex(....);
        echo json_encode($output);

then you set your datatable to use "local data variable" in the AJAX return and NOT in the JQUERY window load function, and you can then set the datatable data source to an object in your AJAX received. But this is not so easy to do.
MarkProgrammerAuthor Commented:
That's what i'm looking to do .. I want to set the data source to an object while still using server-side paging, etc.

The paging/sorting data from each table will have prepended names to the variables so my server-side script knows which "SSP::complex" it should be applied to
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.