Re: Browse Table Filter Options
Posted: Tue Feb 01, 2022 4:43 pm
Btw. Form without dropdown filters and without WHERE clause in SQL works properly ...
Code: Select all
$('#nuBrowseTitle0_select').parent().unbind("touchstart");
Code: Select all
function addBrowseTitleDropDown(index, data) {
var dropId = "nuBrowseTitle" + index + "_dropdown";
var list = document.createElement('select');
...
Code: Select all
function addBrowseTitleDropDown(index, data) {
var dropId = "nuBrowseTitle" + index + "_select";
var list = document.createElement('select');
...
Code: Select all
SELECT
tbl_knihy.*,
tbl_autori.autor,
tbl_knihy.rok,
tbl_formaty.format,
tbl_jazyky.jazyk,
tbl_kategorie.kategoria,
tbl_media.medium,
tbl_serie.seria,
tbl_umiestnenia.umiestnenie
FROM
tbl_knihy
JOIN tbl_autori ON tbl_knihy.tbl_autori_id = tbl_autori.aut_id
JOIN tbl_formaty ON tbl_knihy.tbl_formaty_id = tbl_formaty.for_id
JOIN tbl_jazyky ON tbl_knihy.tbl_jazyky_id = tbl_jazyky.jaz_id
JOIN tbl_kategorie ON tbl_knihy.tbl_kategorie_id = tbl_kategorie.kat_id
JOIN tbl_media ON tbl_knihy.tbl_media_id = tbl_media.med_id
JOIN tbl_serie ON tbl_knihy.tbl_serie_id = tbl_serie.ser_id
JOIN tbl_umiestnenia ON tbl_knihy.tbl_umiestnenia_id = tbl_umiestnenia.umiest_id
WHERE
((autor = '#nuBrowseTitle1_select#' AND LOCATE('#', '#nuBrowseTitle1_select#') <> 1 )
OR '#nuBrowseTitle1_select#' = '' OR LOCATE('#', '#nuBrowseTitle1_select#') = 1)
AND
((kategoria = '#nuBrowseTitle4_select#' AND LOCATE('#', '#nuBrowseTitle4_select#') <> 1 )
OR '#nuBrowseTitle4_select#' = '' OR LOCATE('#', '#nuBrowseTitle4_select#') = 1)
AND
((medium = '#nuBrowseTitle5_select#' AND LOCATE('#', '#nuBrowseTitle5_select#') <> 1 )
OR '#nuBrowseTitle5_select#' = '' OR LOCATE('#', '#nuBrowseTitle5_select#') = 1)
AND
((jazyk = '#nuBrowseTitle3_select#' AND LOCATE('#', '#nuBrowseTitle3_select#') <> 1 )
OR '#nuBrowseTitle3_select#' = '' OR LOCATE('#', '#nuBrowseTitle3_select#') = 1)
ORDER BY
tbl_knihy.nazov ASC
Code: Select all
if (nuFormType() == 'browse') {
var arrAutori = JSON.parse(getAutori());
addBrowseTitleDropDown(1, arrAutori); // add dropdown to column 2 (index 1)
var arrKategorie = JSON.parse(getKategorie()); // add dropdown to column 5 (index 4)
addBrowseTitleDropDown(4, arrKategorie);
var arrMedia = JSON.parse(getMedia()); // add dropdown to column 6 (index 5)
addBrowseTitleDropDown(5, arrMedia);
var arrJazyky = JSON.parse(getJazyky()); // add dropdown to column 4 (index 3)
addBrowseTitleDropDown(3, arrJazyky);
}
// Function to add a dropdown to a title of a Browse Screen
// * @param {number} index - browse index where the dropdown should appear
// * @param {object} data - array to populate the dropdown
function addBrowseTitleDropDown(index, data) {
// var dropId = "nuBrowseTitle" + index + "_dropdown";
var dropId = "nuBrowseTitle" + index + "_select";
var list = document.createElement('select');
list.setAttribute("id", dropId);
var w = nuCurrentProperties().column_widths[index] - 10;
list.setAttribute('style', 'width:'+ w +'px');
for (var i = 0; i < data.length; i++) {
var opt = document.createElement('option');
opt.innerHTML = data[i];
opt.value = data[i];
list.appendChild(opt);
}
// append select to the browse title
$('#nuBrowseTitle'+index).append('<br/>').append(list);
$('#'+dropId).on('change', function (e) {
// var optionSelected = $("option:selected", this);
nuSetProperty(this.id,this.value);
nuSearchAction();
});
$('#nuBrowseTitle'+index).on('mousedown' , '> select' , function(e){
e.stopPropagation();
});
var dropValue = nuGetProperty(dropId);
$("#"+dropId).val(dropValue);
}
if( nuFormType() == 'browse') {
$('#nuActionHolder').css({'height': '60px'});
}
Code: Select all
$('#nuBrowseTitle0_select').parent().unbind("touchstart");