search in nested object

search in nested object

zehgehzehgeh 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 :smile:

Test case: http://live.datatables.net/soxerijo/2/edit

Answers

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949
    edited May 2021

    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

  • zehgehzehgeh Posts: 7Questions: 2Answers: 0
    edited May 2021

    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

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    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

This discussion has been closed.