Project first in results, subprojects after

Project first in results, subprojects after

tekuilatekuila Posts: 24Questions: 5Answers: 0

Hey

My client is asking for this:

The search results display the "projects" first and the associated "subprojects" after.

So when you search for the projects name, the project eill show in results along eith the subprojects whicj will display below, on their own rows.
If you search for the subproject, the associated project will still show above, including the rest of the associated subprojects below.

And he do not wish to click on the projects row to then display the subprojects on the child row. All on their own row without clicking.

Do you have any link or can you point me somewhere where I can figure this out?

It seems a bit complex task to me.

Thanks ?
Jonas

Answers

  • tekuilatekuila Posts: 24Questions: 5Answers: 0

    Sorry for spelling mistakes, I'm typing on the phone.

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    This would be a likely starting-point:
    https://datatables.net/examples/api/row_details.html

    But I'm afraid the extra complications you require aren't catered for out-of-the-box.

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    Another option to look at is the RowGroup extension.

    Kevin

  • tekuilatekuila Posts: 24Questions: 5Answers: 0
    edited August 2019

    Thanks guys, I made it work and it's rather simple.

    <table>
    <thead>
    the <tr>'s...
    </thead>
    <tbody>
    <tr> for the project (incl. a hidden column with text "project" + a hidden column with all of the associated subproject's names)
    <tr> for the associated subprojects (incl. a hidden column with text "subproject" + a hidden column with the associated project's name)
    </tbody>
    </table>
    

    Then order the results after the hidden columns with "project" and "subproject" texts.

    And then

    "rowGroup": {
          "dataSrc": 2 (the column for the project's name, and make sure to put the associated projec's name in column 2 for subprojects too)
    },
    
  • tekuilatekuila Posts: 24Questions: 5Answers: 0

    Or so I thought... The subprojects are still all displayed in the bottom, instead of below the associated project.

    The rowGroups are being duplicated now. Screenshot -> https://ibb.co/X4H0jGw

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774

    This example works:
    https://datatables.net/extensions/rowgroup/examples/initialisation/simple.html

    Without actually seeing the table with the problem it would be hard to say what the problem is. Please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • tekuilatekuila Posts: 24Questions: 5Answers: 0
    edited August 2019

    The rowGroup functionality alone is not quite what I need.
    But I found another solution using Ransacker (with Rails).

    Thanks for the help!

  • tekuilatekuila Posts: 24Questions: 5Answers: 0
    edited August 2019

    Sorry, I was being a noob.

    It sorted the subprojects in the bottom, because I sorted the datatable after the column with "project" and "subproject".

    The solution was to loop through the records with an index-number-column, and then sort the results after the index numbers.

    It works perfect now!

This discussion has been closed.