0

enter image description hereI am unable to display multiselect picklist values using bootstrap library.Can anyone check wht wrong i am doing.

Below is the class and vf page -

Class -

public class testcon {
    public string check {get;set;}
     public Product2 changer{get;set;}
      public testcon(ApexPages.StandardController controller) {
    this.changer = (Product2)controller.getRecord();
  }

     public List<selectOption> getPax() {
    List<selectOption> options = new List<selectOption>();
    String fullName;
    for (Product2 p : [SELECT Id,Name  from Product2 ]) {
      fullName = p.Name; 
      options.add(new selectOption(fullName, fullName));
     }
     return options;
  }

}

Vf page -

<apex:page standardstylesheets="false"  showHeader="true" extensions="testcon" standardController="Product2">
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<html>
<head>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" type="text/css" />
<script src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>

<script type="text/javascript" src="https://davidstutz.github.io/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="https://davidstutz.github.io/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" type="text/css"/>

  <meta charset="utf-8"/>

</head>
<apex:form>

<select id="example-multiple-selected" multiple="multiple" >

    <apex:repeat value="{!changer.Name}" var="stage">  
                <option value="{!pax}">{!pax}</option>  
            </apex:repeat>  
</select>



<script type="text/javascript">
    $('#example-multiple-selected').multiselect();
</script>

</apex:form>
</html>
</apex:page>

Regards

2

Try changing:

<apex:repeat value="{!changer.Name}" var="stage">

to:

<apex:repeat value="{!pax}" var="stage"> 

your repeat should iterate on the list of product names.

edit:

change in page

<select id="example-multiple-selected" multiple="multiple" >
    <apex:repeat value="{!pax}" var="stage">  
        <option value="{!stage.value}">{!stage.label}</option>  
    </apex:repeat>  
</select>

Use a wrapper in controller:

public class Multiselect_BS {
    public string check { get;set; }
    public Product2 changer{ get;set; }
    public Multiselect_BS(ApexPages.StandardController controller) {
        this.changer = (Product2)controller.getRecord();
    }
    public List<ProductWrapper> getPax() {
        List<ProductWrapper> options = new List<ProductWrapper>();
        for (Product2 p : [SELECT Id,Name  from Product2 ]) {
            options.add(new ProductWrapper(p.Id, p.Name));
        }
        return options;
    }

    // using wrapper
    public class ProductWrapper {
        public String value { get; set; }
        public String label { get; set; }
        public ProductWrapper(String value, String label) {
            this.value = value;
            this.label = label;
        }
    }
}

Adding screenshot: enter image description here

| improve this answer | |
  • Hi rahui..its coming like above.. – learnjqueery Oct 11 '16 at 11:52
  • updated the post, you should wrapper list instead of select options. – Raul Oct 11 '16 at 12:01
  • Thanks rahul for the save.. I there any way to implement slds on this vage.. – learnjqueery Oct 11 '16 at 12:31
  • I am new to SLDS :) – Raul Oct 11 '16 at 12:40
  • ok .. last question if u dont mind.. can we remove the checkbox and only show a tick..is it possible – learnjqueery Oct 11 '16 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.