Inhalte aufrufen

Profilbild

Searchable DropDown List

DropDown

2 Antworten zu diesem Thema

#1 llegrand

llegrand

    Newbie

  • Members
  • 5 Beiträge

Geschrieben: 19 April 2018 - 15:35

Hi,

 

New in SmartStore Customization... ;)

 

I try to implement a new DropDown list to select some value when creating a new Address during Checkout.

I want that DropDown list searchable like the Country one.

 

When trying to implement it in "_CreateOrUpdateAddress" (by copy pasting elements related to Country :D), I get my list working properly, but without Search box into it.

 

Sample code :

    <div class="form-group row">
        @Html.LabelFor(model => model.SelectedAddressId, new { @class = "col-{0}-3 col-form-label".FormatInvariant(breakpoint) })
        <div class="col-@breakpoint-9">
            @Html.DropDownListFor(model => model.SelectedAddressId, Model.AvailableAddresses, new { @class = "form-control" })
            @Html.ValidationMessageFor(model => model.SelectedAddressId)
        </div>
    </div>  

When replacing "Model.AvailableAddresses" by "Model.AvailableCountries", the search box appears...

 

What did I miss ?

 

Thanks for your help.

 


  • Stephennuh gefällt das

#2 Murat Cakir

Murat Cakir

    SmartStore AG

  • Administrators
  • 1071 Beiträge

Geschrieben: 19 April 2018 - 17:25

I suppose that's because the searchbox is only displayed if there are at least 12 dropdown items. However you can change this behaviour:

@Html.DropDownListFor(model => model.SelectedAddressId, Model.AvailableAddresses, new { @class = "form-control", data_minimum_results_for_search = 0 })

data_minimum_results_for_search corresponds to the native select2 option minimumResultsForSearch.


Murat Cakir
SmartStore AG


#3 llegrand

llegrand

    Newbie

  • Members
  • 5 Beiträge

Geschrieben: 20 April 2018 - 07:59

Yes it was !

Thanks for your help !





Auf dieses Thema antworten



  

Auch markiert mit einem oder mehrerer dieser Schlüsselwörter: DropDown