Multi value fields filtering

Multi value fields filtering

Macaroni91Macaroni91 Posts: 5Questions: 2Answers: 0

Hello,
I have columns with multi value fields for example : "A,B,C" and also fields with multi value fields and html (<br>) for example "A, B <BR> C" (I used the column render to produce this output)
I want to use some kind of column filtering: https://datatables.net/examples/api/multi_filter_select.html
OR SearchPanes extension .

The problem is that they take the entire field value, so the select option for the example above will be only "A,B,C" instead of 3 options for each of the letters: "A" "B" "C" .
I don't know how to approach this problem, and I would appreciate any directions to solve this.
Thank you very much!

This question has an accepted answers - jump to answer

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236
    Answer ✓

    Hi @Macaroni91 ,

    Maybe take a look at this example. It shows searchpanes using arrays to filter data. Are you able to use that?

    Thanks,
    Sandy

  • Macaroni91Macaroni91 Posts: 5Questions: 2Answers: 0

    Thank you @sandy !
    I am able to use this if the data for a certain column contains only an array.
    However, when there are several objects (that I separate with <br>) and each object has an array, it doesn't work.
    The data looks like this :

       "variant": [
            {
                "name": "ATOH1",
                "inheritance": null,
                "pmids": [
                    "321321"
                ],
                "dvd_link": "11:76868004:C>T"
            },
            {
                "name": ANKRD36",
                "inheritance": "X-Linked",
                "pmids": [
                    "321",
                    "331"
                ],
                "dvd_link": "9:75369733:C>T"
            }
        ],
    

    If I'm trying to filter for a specific "pmid" for example I tried the following code that doesn't filter well :

    data: "variant[]",
    render: {
    _: "[<br> ].pmids",
    sp: "[].pmids",
    },

    However filtering for "dvd_link" works well :

    data: "variant",
    render: {
    _: "[<br> ].dvd_link",
    sp: "[].dvd_link",
    },
    searchPanes: {
    orthogonal: "sp",
    },

  • Macaroni91Macaroni91 Posts: 5Questions: 2Answers: 0
    edited October 2020

    Thank you @sandy !
    I am able to use this if the data for a certain column contains only an array.
    However, when there are several objects (that I separate with <br>) and each object has an array(that i separate with commas) it doesn't work.
    The data looks like this :

           "variant": [
                {
                    "name": "ATOH1",
                    "inheritance": null,
                    "pmids": [
                        "321321"
                    ],
                    "dvd_link": "11:76868004:C>T"
                },
                {
                    "name": ANKRD36",
                    "inheritance": "X-Linked",
                    "pmids": [
                        "321",
                        "331"
                    ],
                    "dvd_link": "9:75369733:C>T"
                }
            ],
    

    If I'm trying to filter for a specific "pmid" for example I tried the following code that doesn't filter well :

     data: "variant[]",
            render: {
              _: "[<br> ].pmids",
              sp: "[].pmids",
            },
            searchPanes: {
              orthogonal: "[].pmids",
            },
    

    However filtering for "dvd_link" works well :

      data: "variant",
            render: {
              _: "[<br> ].dvd_link",
              sp: "[].dvd_link",
            },
            searchPanes: {
              orthogonal: "sp",
            },
    
  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Macaroni91Macaroni91 Posts: 5Questions: 2Answers: 0

    I solved the problem, I needed to call orthogonal: "sp", instead of using orthogonal: "[].pmids" .
    It works well, thank you!

This discussion has been closed.