Can I set a filter from one page to another DataTable?
Can I set a filter from one page to another DataTable?
Hello,
I have an overview page where they can see how many sub categories one person had, for example a person Joe Doe have an overview page which has said it had 8 requests.
I want to make from this number 8 a link to another existing DataTable (query.php) and open this page which this 8 records.
The query.php looks like this:
<div class="pb-5">
<table id="table-request" class="table-responsive stripe hover row-border compact nowrap">
<thead>
<tr>
<th>Clientnumber</th>
<th>Name</th>
<th>Product</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
$(document).ready(function() {
new DataTable('#table-request', {
ajax: {
url: '/crm/ajax/request-data.php',
type: 'POST'
},
columns: [
{ data: 'request.clientnumber' },
{ data: 'request.name' },
{ data: 'request.product' }
],
columnDefs: [
{ targets: [0], className: 'dt-body-left'},
{ targets: [0], render: DataTable.render.number( '.', ',', 0 ) }
],
order: [[0, 'asc']],
pagingType: 'full_numbers',
pageLength: 25,
language: {
url: 'https://cdn.datatables.net/plug-ins/1.11.5/i18n/nl-NL.json'
},
search: {
smart: false
}
});
If the client has clientnumber 3, how can I make a link from the overview page which opens the query.php and filter out only clientnumber 3? So only 8 records are visible?
Kind regards,
Arie

Answers
You can use the DeepLink plugin to get the search string parameter and perform a search.
Alternatively you can use Javascript URLSearchParams to get the query parameters and use either
searchorcolumn().search()as appropriate.Kevin
Hi Kevin,
Tnx for pointing me the the Deeplink plugin.
I have now an URL on the overview page, query.php?search.search=3 which loads the query.php but unfortually it loads every record, not only clientnumber 3.
I have edit the query.php with this:
Any idea why I get all the records in stead of only clientnumber 3?
And is it possible to look into a certain column for clientnumber? Because in the other columns the number 3 can also exist. I only need to look into column 0.
Best regards,
Are you able to link to the page so I can take a look at it please?
Is it missing a
#for an ID selector? How does it relate to the#requesttable? Are you displaying two tables on this results page?Yes, you can perform a filter on a specific column.
column().search()with the API orsearchColsfor initialisation.I'd focus on getting the search information working first.
Allan
It doesn't look like you are using server side processing so if you want to only return certain records for the ajax request to
/crm/ajax/request-data.phpthen you will probably want to useajax.datato send the search parameters to the server and the server script will need to filter the results based on the sent search parameters. The deeplink plugin won't be useful for this case.Kevin