function initMainTable(cId = '') { $table.bootstrapTable('destroy').bootstrapTable({ method: 'get', pagination: true, cache: false, pageSize: 250, sidePagination: 'server', queryParamsType: '', ajax: function (params) { let catId = $('#categoryFilter').val() || 0; let limit = params.data.limit || 100; let offset = params.data.offset || 0; // Get the search text from Bootstrap Table's internal state let search = params.data.search ? encodeURIComponent(params.data.search) : ''; // NEW URL STRUCTURE: /list/catId/limit/offset?search=... let fetchUrl = baseProductUrl + "/custom/list/" + catId + "/" + limit + "/" + offset; if (search) { fetchUrl += "?search=" + search; } $.ajax({ type: "GET", url: fetchUrl, success: function (res) { params.success({ total: res.total, rows: res.rows }); }, error: function (err) { params.error(err); } }); } uniqueId: 'id', formatSearch: function () { return 'Zoeken' }, search: true, searchSelector: '#customSearch', searchHighlight: true, formatNoMatches: function () { return 'Geen resultaten gevonden'; }, buttonsToolbar: '.buttons-toolbar', loadingFontSize: '20px', paginationPreText: 'Vorige', paginationNextText: 'Volgende', loadingTemplate: function (loadingMessage) { return '' + '' + '' + 'Gegevens aan het ophalen' + '' + '' + '' }, rowAttributes: (r) => ({ 'class': 'tableRow', 'data-id': r.id }), responseHandler: function(res) { // If the response is already an object with 'rows', return it directly if (res && res.rows) { return { total: res.total, rows: res.rows }; } // Fallback for old array format if necessary return Array.isArray(res) ? res : []; } }); }