Filter table by field come from JSON
Filter table by field come from JSON
hviegas
Posts: 11Questions: 1Answers: 0
Hello everybody,
I have extensively searched and cannot find the answer, I intend to filter the table with a field from the HTML page.
Below my code and I intend to filter by the field "Owner.Own_Id" where I have in the code (search:"1").
Code:
function loadDataTable() {
dataTable = $('#tblData').DataTable({
"ajax": {
"url": "/Admin/Property/GetOwners",
type: "GET",
contentType: "application/json",
dataType: "json",
success: function(date) {
alert(data.d.date)
}
},
pageLength: 10,
searchCols: [null, { search: "1" , "regex": true }, null, null, null, null, null, null],
lengthMenu: [2, 5, 10, 20, 50, 100, 200, 500],
"columns": [
{ "data": "prop_Id", "width": "3%" },
{ "data": "owner.own_Id", "width": "3%" },
Thanks
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Replies
I assume you mean a field from your data table.
You are not saying from which table row your search field should be coming from. I assume it is from the selected row (if any) in case you are using the "select" extension.
Use Markdown please (see below).
thank you very much for the support,
I ended up using another solution, in the future I will filter directly in JSON.
Below is the solution used: