Search Panes - dealing with arrays when not using ajax json data

Search Panes - dealing with arrays when not using ajax json data

BartoszJarmuzBartoszJarmuz Posts: 9Questions: 3Answers: 0

Hello,
I saw the example of how to work with an array when using ajax json data
https://datatables.net/extensions/searchpanes/examples/advanced/renderSearchArrays.html

Is that also possible with a 'statically' generated table, i.e. without ajax? If so - any hint on how?
Cheers

Answers

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    Is that also possible with a 'statically' generated table, i.e. without ajax? If so - any hint on how?

    The data source doesn't matter. What does matter is the structure of your original data. You may need to handle the orthogonal data with columns.render. Can you build a simple test case representing your data and a description of what you except so we can help?
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    Here is an example where I need to shorten a filepath:

                {
                    "data": "filename",
                    "title": "Filename",
                    searchPanes: {
                        orthogonal:'sp',
                    },
                    render: function (data, type, row) {
                        if (type === 'sp') {
                            // test/camelot logs/CDR_06h_28m_52s/cdr_Flow 1 DID B.txt/cdr_Flow_1_DID_B.txt
                            <code to shorten filepath>
                            return filepath;
                        }
                        return data;
                    }
                },
    

    Kevin

  • BartoszJarmuzBartoszJarmuz Posts: 9Questions: 3Answers: 0

    Hi Kevin
    Yeah, you're right - I managed to get to the render part indeed.
    Here's the example I created.
    Basically, I need the 4th column to be treated as array and shown in the panes (preferably with a 'tag like' formatting).

    http://live.datatables.net/toraqudo/1/edit?html,css,js,output

  • kthorngrenkthorngren Posts: 20,276Questions: 26Answers: 4,765

    Here is an example:
    http://live.datatables.net/tevisiha/3/edit

    I updated a couple of the tags to have some different data for each row.

    The place to start is to understand the data in the column. I used console.log(data); as the first step to see what Datatables is using as the data. Then I built upon that to eventually use jQuery to loop through all the i tags and extract the desired data points for Search Panes.

    I haven't quite figured out the columns.searchPanes.threshold yet but had to set it to 4 to display the tags.

    Kevin

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    searchPanes.threshold is a value from 0 to 1, so something odd going on here since as you say, it needs a value of 4 to appear.

    I've raised it internally (DD-1350 for my reference) and we'll report back here when there's an update.

    Cheers,

    Colin

  • BartoszJarmuzBartoszJarmuz Posts: 9Questions: 3Answers: 0

    Thank you both!

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    The problem here was that you had 6 unique values over 2 rows, which meant the uniqueness ratio was 3 - something we hadn't anticipated. We've changed this now for columns with array values like yours to be uniqueArrayOptions/totalArrayEntries, so giving a threshold of 6 / 8 = 0.75.

    This has been addressed. It'll be in the next release, but you can confirm the solution by using the nightly releases here. Example here.

    Colin

This discussion has been closed.