Open a datatable with the smart filter preset so only matching rows show
Open a datatable with the smart filter preset so only matching rows show
Been searching for this solution but haven't been able to get it.
One of the columns in my datatable is a hyperlink. When I click it takes me to another datatable.
I want this second datatable to open with its smart filter populated so that only matching results are displayed.
Code:
var table = $('#enr_apps').DataTable({
...
columns: [
{data: null,
render: function (data, type, row) {
// Combine the first and last names into a single table field
var fullName = data.est.StudentFirstName + ' ' + data.est.StudentLastName;
return '<a href="student_parent_edit.php" target="_blank">' + fullName + '</a>';
}
},
On click the page student_parent_edit.php opens and shows all the records in my second datatable. Of course I could pass in a variable to the SQL for this second datatable but if possible I would prefer to pass the var fullName to the smart filter and have it applied. Does anybody know how?
Thanks in advance
Brendon
This question has an accepted answers - jump to answer
Answers
You'd pass the value that should be entered in the search field as a query parameter, and then read that back when initialising the DataTable and use
search
to set that value.See this SO thread for how to get a query string parameter.
Allan
Many thanks Allan.
I don't know why I couldn't find the
search
.I promise I did look!