window.onload = setupFilter;
window.onload = populateTenantFilter;
gridHeaders = [{name: "Test"},{name: "Value"},{name: "Another one"},{name: "And another"},{name: "Last one"}];
//Selecting/Deselecting all values
function setAllTenantSelections(selected) {
var select = document.getElementById("SelectTenant");
for (element in select.children) {
select[element].selected = selected;
showCol(select[element].text, selected);
}
}
//Adding all values from array to list
function populateTenantFilter() {
var select = document.getElementById("SelectTenant");
select.innerHTML = "";
for (i = 0; i < gridHeaders.length; i++) {
var option = document.createElement("Option");
option.innerHTML = gridHeaders[i].name;
select.appendChild(option);
}
//setting all options as selected on load
setAllTenantSelections(true);
setupFilter();
}
//Adding onclick-events to the values
function setupFilter() {
$('select option').on('mousedown', function (e) {
this.selected = !this.selected;
if (this.selected) {
console.log("SELECTED: " + this.text);
showCol(this.text,true);
} else {
console.log("DESELECTED: " + this.text);
showCol(this.text,false);
}
e.preventDefault();
});
}
function showCol(){
//Filtering grid based on selection
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.