Can I make multiple predefined search queries from a select field?
Can I make multiple predefined search queries from a select field?
arie0512
Posts: 29Questions: 7Answers: 0
Hello,
I want to make for my collegues some predefined search queries.
What I want is a select field with predefined seatch queries. For example sometime like this:
<select name="predined_search" id="predined_search">
<option value="name_starts_with_a">Name starts with an A</option>
<option value="city_from_new_jyork">Clients from New York</option>
<option value="age_greater_than_40">Older than 40</option>
</select>
Is this possible with SearchBuilder?
Best regards,
Arie
Answers
To set a predefined filter when using SearchBuilder, use the
searchBuilder.preDefinedoption.Allan
I know this predifined option but that's only working for one search query.
I want to have several search queries to the same datatable so the user can choose which predefined query he would like to see.
Is that possible?
I'm afraid I don't fully understand the question - sorry.
Do you mean you want to have multiple conditions applied to the table when it starts? If so, then
criteriais an array - you can provide multiple conditions, as shown in the second example in the documentation forsearchBuilder.preDefined.Or, do you mean you have somehow stored different predefined conditions, and you want the end user to select which one they want to load the table with? In which case, it would be up to you to provide the UI to let the end user select the condition and you would then assign that to
searchBuilder.preDefined.Or, do you have a list of criteria and you want the end user to be able to pick one of them after the table has been created and have that applied? If so, you could use Buttons along with
searchBuilder.rebuild()to set the SearchBuilder state.Allan
Hi Allan, no need to apologize!
I will try to explain what I want.
I have a page which will have multiple (a href) links to page 2 where a datatable is shown which contains a colum colorball with different colors.
With the first link I want to show only the red balls on page 2 and with the second link I want to show only the blue balls on page 2. (as an example offcourse
)
One option is to set a variable to contain the predefined search. Using the example in the
searchBuilder.preDefineddocs you could do something like this:Kevin
Okay, so you want to apply a filter to the table based on something like a query parameter? I was about to point you to this thread, but I see that was your own thread!
Can you explain to me how what you want here is different from what was discussed there?
Allan
Sorry, I have mis-explained it in my last post, no good will come out when you are trying to end the week to quickly .....
I was confusing with the problem you are refering to, this is another challenge.
I have page which has a datatable and I want to have an Select field above this datatable so users can switch to a pre-defined view.
What I have so far is this, found on https://datatables.net/examples/api/regex.html
HTML
JS
If Red is chosen from the Select field than column index 4 must only show the records with red.
I get now an error in the console "Uncaught ReferenceError: ChangeView is not defined"
Placing this function outside the document.ready will get an error "Uncaught ReferenceError: table is not defined"
Is there another option to run a function inside the datatable script?
Loose the
onChangeattribute and in place of yourChangeViewfunction do:Allan
Tnx Allan, that did the trick!
In my example I explain it with a simple example but I have 2 questions:
I want in some predefined search queries also a second condition, I have a textfield "already_checked" which contains Yes or No, for example I want in column 4 the red colors where in column 10 (already_checked) the value is No. Is that possible?
Is it possible with your solution to have several different search queries, for example search for red in column 4 and search for blue in column 6? Because in the select field there will not only be a search query in column 4.
Have a nice weekend!
Arie
1) Sure that is possible. Use
URLSearchParamsto get the query parameter, as we discussed in your previous thread, and tweak the search to suit whatever search condition you need.2) Yes. My example code above applied a search to column index 4 (
.column(4).search(x)). There is no reason why you can't extend that to have another search term on another column.Allan