filter checkbox , count, logic and/or multiple select in query

isiway

Member
Hello,
in a list of glues I have a filter I have a checkbox-element "Item XY" with 10 possible values to mark.

When filling out this filter I want a maximum of 2 checkboxes to be filled out otherwise it should not be possible to send the filter.

When I add just a simple javascript to the element "Choose 2 Items" like "alert ('message'); I can see that it is excuted in the form but not in the evaluation of the filter.
Question 1: How do I add validation to the filter?

Question 2:
When I mark f.e. 2 items of the checkbox like value 1 and value 2 the resulting query seems to be something like

select from glues where Item XY= value 1 Item XY=value 2.

Since the field Item XY is a dropdown multiselect element I need to find all glues which have
Item XY= value 1 AND Item XY=value 2.

How do I do that?

Thanks a lot,
Carola
 
There are no validations on the filter. You would need to add some custom js code to achieve this, and will also need to update from git hub as I had had to add selectors to the filter list's <tr>s to make them selectionable with the following js code which should be placed in a file /components/com_fabrik/js/list_X.js where X is your list's id.:

Code:
// This is the full element name for the filter
var element = 'element_test___drodpown1';
 
// Stores the number of checkboxes selected.
var counter = document.getElement('*[data-filter-row=' + element + ']').getElements('input[type=checkbox][checked]').length;
 
// Set this to the number of checkboxes you want checked
var max = 2;
 
document.getElement('*[data-filter-row=' + element + ']').getElements('input[type=checkbox]').addEvent('click', function (e) {
if (e.target.checked) {
if (counter < max) {
counter ++
} else {
alert('counter is at max');
e.target.checked = false;
return false;
}
} else {
counter --;
}
 
})
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top