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
Ram Manohar GRam Manohar G 

Disable specific picklist in pageblocktable. Visualforce apex

Hi ,
I have a pageblock table contains picklist column. If the picklist in a column contains only one value it should be disabled .How can i achive this 

<apex:column header=' '>
<apex:selectList value="{!selectedCountry}" multiselect="false" > <apex:selectOptions value="{!CountriesOptions}"/> </apex:selectList>
James LoghryJames Loghry
You'll want to use the rendered attribute on either the apex:column (for hiding the entire column) or on the apex:selectList (a blank column, without the picklist).

The rendered attribute might look something like:
rendered="{!AND(NOT(countriesOptions.empty),countriesOptions.size > 1)}"

Antonio ManenteAntonio Manente
You could go James' route and not render the elements. One option I could think of is to utilize the 'disabled' attribute on a selectList.
<apex:column header=' '>
  <apex:selectList value="{!selectedCountry}" multiselect="false" disabled="{!oneOption}">
    <apex:selectOptions value="{!CountriesOptions}"/> 
And in your controller implement a check to set the "oneOption" variable to true when there is only one 'CountriesOptions' object in the List and false otherwise.