Search on rows attributes
Search on rows attributes
Emyleen
Posts: 21Questions: 8Answers: 0
Hello!
I'm trying to make a search engine on my datatable, and I have a problem.
I have a multiple select in my search engine and when some options are selected I want to filter my datatable. But now I don't see how! Can you help me?
This is my code :
Thank you!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Your going to need to integrate that code sample into a fully functioning example (with some comments explaining your custom code) so we can better understand it.
This is more part of my code http://www.bootply.com/1SsZwFgwXT
Thanks for the example. Unfortunately I do not understand how the code logic, so I can't answer the question. I think I almost understand it.Can you describe how the user would use the search engine and what results you expect?
In fact the user can select multiple choices in the drop down list, and when he selects a choice (on the change of the select) it must "filter" the display of the DataTable.
In my code i want to search() only on rows that are in rowlist :
$datatable.DataTable()
.rows(rowlist)
.search(search)
.draw();
But this code doesn't work :/
rowlist is an array that contains element of the DOM, the rows that I want in the DataTable.
Yes you can search on cell attributes - see the orthogonal data documentation.
Allan
Ok... but I preferred to look on row attributes because my rows looks like that :
<tr data-attr1="1,25,6" data-attr2="2,85,4,0">...</tr>
Too bad... I'll manage otherwise. Thanks anyway.
if the attributes contain row numbers, then you would convert that to an array and use it as a selector for rows().
http://datatables.net/reference/api/rows()
If the attributes contain row IDs, then you should still be able to convert list of IDs into an array and use that as a selector
http://datatables.net/reference/type/row-selector - see the section on "string - #ID"
For my Row ID I use a created column that is "ID" + the real ID, ID1, ID2, ID3, etc. This helps me understand what value I'm looking at when I debug.
from the documentation:
Hopefully you can see how to adapt this to your code.