function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pothi AbisheikPothi Abisheik 

how to fix the width of a dependent picklist insie a apex:repeat tag It is not accepeting any of the css styles eg: Width:150px width:!important need help on this

Best Answer chosen by Pothi Abisheik
Suraj TripathiSuraj Tripathi
Hi  Abisheik,
I have implemented the code in my Org it is working fine. Below is the code. Please try that code.

VisualForce Code :


<apex:page controller="test">   
<body>
    <apex:form>
        <apex:repeat value="{!contacts}" var="Page1">
            &nbsp; <apex:inputField value="{!Page1.LeadSource}" style="width:400px"/><br/>
            &nbsp; <apex:inputField value="{!Page1.CleanStatus}"/> 
        </apex:repeat>
    </apex:form>
</body>
</apex:page> 

Apex Controller :
public class test{
   
    public List<Contact> contacts{get;set;}
    public test(){
        contacts = [SELECT LeadSource, CleanStatus FROM Contact LIMIT 1000];
    }
}     

Screenshot:
1. First PickList is of standard size and another Picklist is with width:
400px
User-added image

Set the width of PickList according to your requirement.  Hope it Helps you. Mark this answer Solved if it resolves your query.


Regards ,
Suraj

All Answers

Suraj TripathiSuraj Tripathi
Hi  Abisheik,
Below is code for your requirement. It is working fine in my Org. I have used a Standard Object 'Contact'

VisualForce Code :
<apex:page controller="test">
    <style>
        .redColor{
            color : red;
        }
        .blueColor{
            color : blue;
        }
    </style>
    <apex:variable var="index" value="{!1}"/>
    <apex:repeat value="{!contacts}" var="contact">
        <span class="{!IF(MOD(index,2)==0,'redColor','blueColor')}">{!contact.Name}</span><br/>
        <apex:variable var="index" value="{!index+1}"/>
    </apex:repeat>
</apex:page>

Apex Controller :
public class test{
   
    public List<Contact> contacts{get;set;}
    public test(){
        contacts = [SELECT ID, Name FROM Contact LIMIT 1000];
    }
}

Screenshot:
User-added image

Make changes in the style according to you. I have changed the color of the Contacts, you can set the width as well. Hope it Helps you. Mark this answer Solved if it resolves your query.

Regards ,
Suraj
Pothi AbisheikPothi Abisheik

<apex:repeat value="{!coWrapperList}" var="Page1">
<apex:outputLabel >Objective1222</apex:outputLabel> <apex:inputField value="{!page1.compl.Compliance_Objective1__c}" style="width:150px" > <span class = "width:150px"></span> </apex:inputField> </apex:pageBlockSectionItem>
</apex:repeat>

Suraj the objective is a dependent picklist and I cannot fix the size of it it would be helfpul if u clarify Thanks in advance
Suraj TripathiSuraj Tripathi
Hi  Abisheik,
I have implemented the code in my Org it is working fine. Below is the code. Please try that code.

VisualForce Code :


<apex:page controller="test">   
<body>
    <apex:form>
        <apex:repeat value="{!contacts}" var="Page1">
            &nbsp; <apex:inputField value="{!Page1.LeadSource}" style="width:400px"/><br/>
            &nbsp; <apex:inputField value="{!Page1.CleanStatus}"/> 
        </apex:repeat>
    </apex:form>
</body>
</apex:page> 

Apex Controller :
public class test{
   
    public List<Contact> contacts{get;set;}
    public test(){
        contacts = [SELECT LeadSource, CleanStatus FROM Contact LIMIT 1000];
    }
}     

Screenshot:
1. First PickList is of standard size and another Picklist is with width:
400px
User-added image

Set the width of PickList according to your requirement.  Hope it Helps you. Mark this answer Solved if it resolves your query.


Regards ,
Suraj
This was selected as the best answer
Suraj TripathiSuraj Tripathi
Thank you, Abisheik for selecting my answer as best. It's my pleasure to help you.
Pothi AbisheikPothi Abisheik
Thanks Suraj but the condition is not working 
if I use style attribute inside inputField it is not accepting the change Please do help on this suraj