i am trying to make a collapsable multi-select options element using bootstrap, it goes this way you have multiple filters then those filters are linked to another request that then brings out the options under that filter, could not manage to use checkboxes so i used the bootstrap lib. “bootstrap select”, but it is refusing to expand, knowing that the values are being loaded, check the picture, i will attach my code Please help.
this is the part of the code i am facing trouble with:
<div class="row">
<div class="col-12 main-content">
<div class="d-flex justify-content-between align-items-center">
<h1 class="col-9">MaknoonMap</h1>
<img class="col-3 main-logo" src="./Maknoon_Logo.svg"/>
</div>
<div class="col-3 section" id="main-filter-container">
<div id="filtersContainer"></div>
<button class="btn-primary" onclick="navigateToURL()">تصفية</button>
</div>
<div class="map-area col-12">
<gmp-map id="DEMO_MAP_ID" center="24.684239941494525,46.707254067257256" zoom="10" map-id="DEMO_MAP_ID" style="height: 800px">
<div id="marker-container"></div>
</gmp-map>
</div>
</div>
<div class="col-3 d-none d-lg-block sidebar" id="sidebar">
<div class="searchBarContainer">
<input class="searchBar" type="text" id="searchBar" placeholder="ابحث هنا!">
<button class="btn-primary" onclick="focusAndHighlightCheckboxByLabel(document.getElementById('searchBar').value)">بحث</button>
</div>
</div>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasSidebar" aria-labelledby="offcanvasSidebarLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasSidebarLabel">Menu</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="searchBarContainer">
<input class="searchBar" type="text" id="searchBar2" placeholder="ابحث هنا!">
<button class="btn-primary" onclick="focusAndHighlightCheckboxByLabel(document.getElementById('searchBar2').value)">بحث</button>
</div>
<div class="offcanvas-body">
<div id="offcanvasFiltersContainer"></div>
<button class="btn-primary" onclick="navigateToURL()">Filter</button>
</div>
</div>
</div>
</div>
function fetchFilters() {
$.ajax({
url: "https://erp.maknon.org.sa/portal/map/init",
method: "GET",
timeout: 0,
xhrFields: { withCredentials: true },
success: function(response) {
const filtersContainer = $("#filtersContainer");
const offcanvasFiltersContainer = $("#offcanvasFiltersContainer");
filtersContainer.empty();
offcanvasFiltersContainer.empty();
Object.keys(response).forEach(filterKey => {
const filter = response[filterKey];
if (filter && Array.isArray(filter.data)) {
const filterSection = createFilterSection(filterKey, filter);
filtersContainer.append(filterSection);
const offcanvasFilterSection = createFilterSection(filterKey, filter, true);
offcanvasFiltersContainer.append(offcanvasFilterSection);
}
});
// Initialize bootstrap-select
$('.selectpicker').selectpicker();
},
error: function(jqXHR, textStatus, errorThrown) {
console.error('There was a problem with the AJAX request:', textStatus, errorThrown);
console.log('Response Headers:', jqXHR.getAllResponseHeaders());
}
});
}
function createFilterSection(filterKey, filter, isOffcanvas = false) {
const sectionId = isOffcanvas ? `${filterKey}SectionOffcanvas` : `${filterKey}Section`;
const filterItems = filter.data.map(item => `
<option id="${filterKey}_${item.id}_${isOffcanvas ? 'offcanvas' : 'sidebar'}" name="${filterKey}" value="${item.id}">${item.name}</option>
`).join('');
return $(`
<div class="section">
<h4 data-bs-toggle="collapse" multiple data-live-search="true" data-bs-target="#${sectionId}">${filter.name}</h4>
<select id="${sectionId}" class="selectpicker collaps show">${filterItems}</select>
</div>
`);
}
this my css:
html,
body {
height: 100%;
margin: 0;
font-family: "Arial", sans-serif;
background-color: #f8f9fa;
}
.container-fluid,
.row {
height: 100%;
}
.col-lg-9,
.col-lg-3 {
height: 100%;
}
.sidebar {
background-color: #2c665d;
color: #e0e0c7;
border-left: 1px solid #e0e0c7;
height: 100vh;
overflow-x: auto;
padding: 20px;
}
.main-content {
padding: 20px;
}
.section h4 {
background-color: #d1c3a6;
padding: 10px;
margin: 10px 0;
cursor: pointer;
user-select: none;
text-align: right;
border-radius: 5px;
transition: background-color 0.3s;
}
.section h4:hover {
background-color: #c3b492;
}
.section ul {
list-style: none;
padding: 0;
margin: 10px 0 0 0;
display: flex;
flex-wrap: wrap;
}
.section li {
margin: 5px 0;
display: flex;
justify-content: flex-end;
align-items: center;
width: 50%; /* Adjusts the width to ensure two items per row */
}
.section input[type="checkbox"] {
margin-right: 10px;
width: 15px; /* Adjust the width as needed */
height: 15px; /* Adjust the height as needed */
transform: scale(1.5); /* Makes the checkbox bigger */
}
.highlighted-checkbox {
background-color: #8b972f;
transition: background-color 0.2s ease;
}
.offcanvas-header,
.offcanvas-body {
padding: 20px;
}
.offcanvas-body .section h4 {
margin: 0;
}
.offcanvas-body .section {
margin-bottom: 15px;
}
.btn-primary {
background-color: #d9f1ee;
border: none;
transition: background-color 0.3s;
width: 100%;
height: 5%;
padding: 15px;
border-radius: 5px;
margin-bottom: 30px;
}
.btn-secondary {
background-color: #2c665d;
color: #fff;
border: none;
transition: background-color 0.3s;
width: 20%;
height: 5%;
padding: 10px;
border-radius: 5px;
}
.btn-primary:hover {
background-color: #24514d;
}
.filterCheckBox {
display: flex;
justify-content: flex-end;
align-items: center;
width: 50%;
text-align: right;
color: blue;
}
/* .filter-bar {
display: flex;
overflow-x: auto;
padding: 10px;
background-color: white;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: sticky;
top: 0;
z-index: 1000;
} */
.filter-item {
display: inline-block;
margin: 0 10px;
padding: 5px 15px;
border: 1px solid #ccc;
border-radius: 20px;
cursor: pointer;
white-space: nowrap;
transition: background-color 0.3s, color 0.3s;
}
.filter-item input[type="checkbox"] {
display: none;
}
.filter-item label {
margin: 0;
cursor: pointer;
}
.filter-item input[type="checkbox"]:checked + label {
background-color: #007bff;
color: white;
}
input[type="text"] {
margin-bottom: 15px;
width: calc(100% - 60px); /* Adjust width to fit the container */
padding: 10px;
border-radius: 5px;
border: 1px solid #ddd;
display: inline-block;
}
#searchBarContainer {
display: flex;
align-items: center;
margin-bottom: 15px;
}
#searchButton {
padding: 10px 20px;
border-radius: 5px;
border: none;
background-color: #2c665d;
color: #fff;
cursor: pointer;
transition: background-color 0.3s;
margin-left: 10px;
}
#searchBar {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ddd;
display: inline-block;
text-align: right;
}
#searchButton:hover {
background-color: #24514d;
}
.filter-bar {
background-color: #f8f9fa;
padding: 10px 0;
margin-bottom: 20px;
}
.filter-dropdown {
margin-right: 10px;
}
.map-area {
height: calc(100vh - 150px);
}
.filter-bar {
background-color: #f8f9fa;
padding: 10px 0;
margin-bottom: 20px;
}
.map-area {
height: calc(100vh - 150px);
}
.search-container {
display: flex;
align-items: center;
}
.search-container .form-control {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.search-container .btn {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.main-logo {
width: 15%;
height: 15%;
object-fit: fill;
border-radius: 20%;
max-height: 50px;
}
enter image description here
i tried making the element closer to the original code
in the bootstrap library but could not manage