KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Dashboard: Select2 placeHolder not showing when ->multiple(false) #2425

Open Andre Van Der Walt opened this topic on on Nov 9, 2021 - 7 comments

Andre Van Der Walt commented on Nov 9, 2021

Hi,

Please assist Select2 placeHolder not showing when ->multiple(false) but showing first item instead. placeHolder only display when ->multiple(true).

Do you have a fix for this?

Thank you,

John commented on Aug 4, 2023

I have the same problem. Did you find any solution for this?

Sebastian Morales commented on Aug 18, 2023

This has been known as an unintended bug of Select2 client js. Would you pls try the following workaround and let us know the result:

  • Add the following CSS rule to your report/dashboard page:
<style>
    .select2-search--inline {
        display: contents; /*this will make the container disappear, making the child the one who sets the width of the element*/
    }

    .select2-search__field:placeholder-shown {
        width: 100% !important; /*makes the placeholder to be 100% of the width while there are no options selected*/
    }
</style>
John commented on Aug 21, 2023

I use Select2 in Dashboard and i don't have any view file. Any suggestion about where to insert the code?

John commented on Aug 21, 2023

I added a custom css file and did what this article says: https://www.koolreport.com/forum/topics/1882 but code didn't work...

Sebastian Morales commented on Aug 25, 2023

Sorry that workaround didn't solve the case. After some more research I think that Select2 follows the default behaviour of the normal Select html element where in single mode the default initial value is the first option.

A solution you can apply right now is adding an empty string value option to the beginning of the Selects' options, i.e adding an empty string element to the data array. Meanwhile we will add a feature to the next version of KoolReport so that Select2 can default to an empty value in single mode if users want it.

John commented on Aug 25, 2023

Well.. in my case i added the string 'Select Year' which is the best solution. Thanks for your effort!

Sebastian Morales commented on Aug 31, 2023

John, just want to inform you that this default non-selected Select2 has been implemented and it will be available in the next release soon.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Dashboard