Search code examples
javascriptbootstrap-4bootstrap-select

Bootstrap selectpicker selected items format


I have multiple selectpicker and i dont understand how to change selected items format. Any suggestions guys?

enter image description here

I read this and found option selectedTextFormat but that's not what i need

$('.selectpicker').selectpicker({
    selectedTextFormat: 'values'
});

Solution

  • Found sollution

    $(window).on('load', function() {
        $('.selectpicker').selectpicker({
            showSubtext: true
        });
    }); 
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.css">
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.js"></script>
    
    <select class="selectpicker form-control" multiple>
        <option data-subtext="Mustard" value="">1</option>
        <option data-subtext="Ketchup">2</option>
        <option data-subtext="Relish">3</option>
    </select>