Bootstrap-multiselect: fixed search box

Created on 7 Oct 2014  路  18Comments  路  Source: davidstutz/bootstrap-multiselect

  1. I have a lot of items
  2. I setted max height
  3. search is enabled
  4. when I'm scrolling the items the search box is scrolled too.

Can I fix search box in some way?

bug

Most helpful comment

I have fixed this using css.
.multiselect-filter { position: sticky; top: 5px; z-index: 1; }

All 18 comments

Currently, I do not have a quick solution. However, I will try some things and add an example to the documentation.

Added this to "Known Issues" for now.

Was this ever fixed?

This feature is important for me, furthermore the "select all" line could be in fixed position as well.

You can add your own class and apply style like below in order to fix the search box.

.fixedHeader-ul
{
overflow-x: scroll;
}
.fixedHeader-ul li
{
}
.fixedHeader-ul li:first-child
{
position: fixed;
background-color: white;
z-index: 10;

}

@n8thegr8 no this was never really fixed. Further, the solution given by @raunaq-itmatrix does not work for me.

@raunaq-itmatrix your solution doesn't work for me, any other solution?

@n8thegr8 @szegediistvan If you can create JSFiddle, I'll look at it and try to help you on that.

@raunaq-itmatrix This is my Codepen:
http://codepen.io/szegediistvan/pen/xwpmzz

Please help me, because i need fixed search box solution.

@szegediistvan

Add following class to your CSS and you are all set ! You just need take care of padding/margin.
.input-group
{
position:fixed;
z-index:100;
width:337px;
background-color:white;
padding:10px;
}

@szegediistvan Is above provided solution worked for you?

No. I would like to fixing li.multiselect-item.filter element, when the options were opened.

You could wrap all the options except filter with some div for custom styling. This worked for me: https://jsfiddle.net/101Lucho/2/
Further, you could add that code to onInitialize configuration option.

@amicel Confirmed! Perfect working solution. And indeed, oninitialized works properly, too.

onInitialized: function(select, container) {
$('.multiselect-container').find('li:not(.multiselect-filter)').wrapAll('<div class="options-wrapper">

');
}

Hey, I have this problem too! Wishing the filter would stay fixed to the top. I'd assume this would be how most people would like it to work.

What if I make pull request for this feature, would you be open to changing the default behaviour @davidstutz ?

I have a workaround. We can move the search element li.filter from ul.multiselect-container element and place it next to the button.multiselect then show/hide the the search element rely on Dropwdown events:

$("#selectElement").multiselect({
    enableFiltering: true,
    onDropdownShown: function () {
        $("li.filter").show();
    },
    onDropdownHidden: function () {
        $("li.filter").hide();
    },
    enableCaseInsensitiveFiltering: true
});
$("li.filter").insertAfter("button.multiselect").hide();

no have solution?

I have fixed this using css.
.multiselect-filter { position: sticky; top: 5px; z-index: 1; }

Was this page helpful?
0 / 5 - 0 ratings