SearchPanes: Finding the selected values

SearchPanes: Finding the selected values

bliksempiebliksempie Posts: 15Questions: 3Answers: 0
edited October 2023 in Free community support

Thanks for your help so far!

I am busy trying to write a server side script for a custom button to search my database, and I need to get the search parameters in order to see what has been posted. I have found the following (as per your previous assistance and some further searching the forums:

var globalSearch = dt.search();
var columnSearch = dt.columns().search();

Which contains the search values for global and columns.

I am still in need of the search values for the searchPanes, with their associated filter "name". I found this answer by Sandy:

$(".dtsp-searchPane table:visible").each(function(t) {
    console.log($(this).DataTable().rows({selected: true}).data().toArray());
})

While that gives me the values selected, I cannot for the life of me figure out how to see which search pane each of the selected arrays of values are associated with. I need to know, for example, that values "MIS-15" and "MIS-16" are selected in the "Tracking Code" search pane. I only have the values MIS-15 and MIS-16 in the above code, not the name (or even the index/target) of the search pane, obviously.

I tried toArray() as follows, but do not know how to interpret the vast if information provided there:

$(".dtsp-searchPane table:visible").each(function(t) {
    console.log($(this).DataTable().toArray());
})

Please advise? I cannot find an example doing what I am trying to achieve. I am a back-end PHP programmer, so JS is a bit baffling to me. :-)

Thanks in advance!

Answers

  • bliksempiebliksempie Posts: 15Questions: 3Answers: 0
    edited October 2023

    I figured this out from some other example, and it looks like it is working. If there is a better way than this, can you plese advise?

            $.each($("div.dtsp-searchPane"), function(i, col) {
                $.each($("tr.selected", col), function(j, row) {
                    if (typeof(panesSearch[i] == "undefined")) {
                        panesSearch[i] = "";
                    }
                    panesSearch[i] += $("span:eq(0)", row).text();
                });
            });
    
  • bliksempiebliksempie Posts: 15Questions: 3Answers: 0

    The above is working well enough for me. You can close this question - does not look like there is a way I can mark my own comment as being a solution? Thank you!

Sign In or Register to comment.