search in nested object
search in nested object
zehgeh
Posts: 7Questions: 2Answers: 0
Hello, I have a nested object and a part of it I want to output in a subtable. I also want to search in it via a search field. However, the search finds nothing in it. I want to search e.g. "Wassermelone" and then output this row. How can I solve that it also searches in the subtable?
Thank you for the help
Test case: http://live.datatables.net/soxerijo/2/edit
This discussion has been closed.
Answers
Datatables will only search in table columns. You can extract the keywords you want to search and place them in a hidden column. Use
columns.render
to extract the keywords you want and build a list for each cell. See this updated example:http://live.datatables.net/soxerijo/3/edit
Comment out
"visible": false
to see what the column data looks like.Kevin
Thank you very much Kevin. This helps me a lot. However, I wanted to push the column dynamically, only that does not work yet. The "details" column is created, but it is not invisible. And I can't search for the contents then either.
Where is my thinking error there?
http://live.datatables.net/soxerijo/4/edit
Datatables doesn't support adding columns after initialization. I've never seen
settings().init().columns.push()
before. Where did you find it?You can create a columns object variable before initializing Datatables and use that for the columns. Something like this:
http://live.datatables.net/soxerijo/8/edit
Kevin