Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82434

How to Keep DataTables SearchBuilder Always Open

$
0
0

Hi everyone,

I am working on a Drupal 10 website where I have integrated the DataTables library along with the SearchBuilder plugin. My goal is to achieve the following functionality:

  • Keep the SearchBuilder UI always open by default, even if no filters are applied.

Ensure the SearchBuilder UI remains open even after applying or modifying filter criteria.

Any guidance or suggestions would be greatly appreciated. Thank you in advance for your help!

// Initialize DataTables
$('.view-id-index_of_archive_files table.views-table').DataTable({
  dom: 'QBfrtip', // Adds SearchBuilder to the DataTable UI
  responsive: true,
  paging: true,
  searching: true,
  searchBuilder: true, // Enable SearchBuilder
  ordering: true,
  searchBuilder: {
    alwaysOpen: true,
    columns: [0, 1, 2], // Apply SearchBuilder only to specific columns (0 = first column, etc.)
 
},

initComplete: function (settings, json) {
  // Ensure SearchBuilder is displayed after DataTable initialization
  const searchBuilderElement = $('.dtsb-searchBuilder');
  if (!searchBuilderElement.hasClass('dtsb-active')) {
    searchBuilderElement.addClass('dtsb-active').show(); // Force it to remain open
  }

      // Automatically add a condition by simulating a click on "Add Condition"
      const addConditionButton = $('.dtsb-add');
      if (addConditionButton.length > 0) {
        addConditionButton.trigger('click');
      }
},
});



});

Viewing all articles
Browse latest Browse all 82434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>