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
renuamirenuami 

SelectList onchange not firing

i have some complex requirement...any help on this is much appriciated!!! thanks..

 

I tried something but not able to get it work...events are not firing...

 

My requirement is, when Web is selected in the Source dropdown then for that row, In the Detail Info column, detail info dropdown should be displayed/enabled. (for all other rows the detail info dropdown should be disabled/hide).

 

if again in the second row, when web is selected in the Source dropdown then again for that row detail info dropdown should be displayed, else it should be disabled or hidden.

 

I have written some thing in OnSelect but it is not firing

 

 

<apex:page controller="controller_test" action="{!init1}">
<apex:form >
<apex:PageBlock>
<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable">
<apex:column headervalue="Source">
<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable">
<apex:selectOptions value="{!Source_Items}"/>
</apex:selectList>
</apex:column>
<apex:column headervalue="Detail Info">
<apex:selectList value="{!Detail_Name}" required="true" multiselect="false" size="1" rendered="{!source_info=='Web'}" >
<apex:selectOptions value="{!Detail_Items}" rendered="{!source_info=='Web'}"/>
</apex:selectList>
</apex:column>
</apex:pageBlockTable>

 

 

<apex:actionFunction name="RRTheTable" action="{!Refresh}" rerender="TheTable"/>


<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

 

 

 

public with sharing class controller_test
{
List<Event> events_info = new List<Event>();
List<String> WhoIds = new List<String>();
List<Contact> Contacts_info = new List<Contact>();

public String source_info,detail_Name;

public String getSource_info()
{
return source_info;
}

public void setSource_info(String source_info)
{
this.source_info= source_info;
}

public String getDetail_Name()
{
return detail_Name;
}

public void setDetail_Name(String detail_Name)
{
this.detail_Name= detail_Name;
}

public List<SelectOption> getSource_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Web','Web'));
options3.add(new SelectOption('Email','Email'));
options3.add(new SelectOption('Phone','Phone'));
return options3;
}

public List<SelectOption> getDetail_Items()
{
List<SelectOption> options3 = new List<SelectOption>();

options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Google','Google'));
options3.add(new SelectOption('Yahoo','Yahoo'));
options3.add(new SelectOption('rediff','rediff'));
return options3;
}


public PageReference init1()
{
events_info=[Select Id,AccountId,What.Name,Who.Name,Who.Email,Who.Id from Event Where OwnerId = :UserInfo.getUserId() and order by Whoid limit 3];
for(Integer i=0;i<events_info.size();i++)
{
WhoIds.add(events_info[i].Who.Id);
}
for(Contact c:[Select Id,Email,Accountid from Contact where Id IN:WhoIds order by Id])
{
Contacts_info.add(c);
}

return null;
}

Public List<Event> getEvent_Results()
{
return events_info;
}

Public List<Contact> getContact_Results()
{
return Contacts_info;
}

public PageReference save()
{
return null;
}

public PageReference Refresh()
{
return null;
}

}

 

 

 

 

Message Edited by renuami on 03-05-2010 05:51 AM
Message Edited by renuami on 03-05-2010 06:41 AM
bob_buzzardbob_buzzard

Try using onchange - I've found that to work successfully.

 

This thread has an example of rerendering parts of the page when the user makes a selection from a list. 

renuamirenuami

Thanks bob.

 

I did tried OnChange(). It din't work either 

 

Any ideas?? I have been working on this since past 3 days :smileysad:

bob_buzzardbob_buzzard
Can you post your page and code with your onchange handling?
renuamirenuami

 I did this way, But always detail info drop down is enabled depending on the source_info value isselected in the last row

Also in the save method always the source info value is the value of the last selected row. How can we get the source_info value for each row in the controller save method?

 

 

 

<apex:page controller="controller_test" action="{!init1}">
<apex:form>
<apex:pageblock>

<apex:pageBlock title="Reporting" >

<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable">

<apex:column headervalue="Source">
<apex:selectList value="{!source_info}" multiselect="false" size="1" onselect="RRTheTable">
<apex:selectOptions value="{!Source_Items}"/>
<apex:actionSupport event="onchange" rerender="list2,look_up"/>
</apex:selectList>
</apex:column>

<apex:column headervalue="Detail Info">
<apex:selectList value="{!Detail_Name}" multiselect="false" size="1" disabled="{!source_info!='Web'}" id="list2" >
<apex:selectOptions value="{!Detail_Items}" />
</apex:selectList>
<apex:inputField value="{!eve.AccountId}" rendered="{!source_info=='Email'}" id="look_up"/>
</apex:column>

</apex:pageBlockTable>

<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>

</apex:pageBlock>
</apex:form>
</apex:page>

 

 

My original requirement was to display dropdown in the Detail info column when Source_info='Web' and display lookUp to Account when  source_info='Email'. For this i am trying below but for some reason rendered and rerender is not working. Not sure if this is because it is in pageblocktable. 

 

Also Event Accountid in inputfield is not displaying lookup, rather the id value is being displayed.

 

Can you please help??

 

I have been trying very hard on this but no luck :smileysad:

 

This is my page

<apex:page controller="controller_test" action="{!init1}">
<apex:pageBlock title="Reporting" >

<apex:pageBlockTable value="{!Event_Results}" var="eve" id="TheTable" >

<apex:Column headervalue="Source" >
<apex:selectList value="{!source_info}" title="Items" size="1" id="List1" >
<apex:selectOptions value="{!Source_Items}" />
<apex:actionSupport event="onchange" reRender="test1, list2A, list2B" status="gettingDetailnames" />
</apex:selectList>
</apex:Column>

<apex:Column headervalue="Detail Info" >
<apex:outputtext rendered="{!source_info=='Web'}" id="test1">here</apex:outputtext>
<apex:selectList value="{!Detail_Name}" title="Detail" size="1" rendered="{!source_info=='Web'}" id="list2A" >
<apex:selectOptions value="{!Detail_Items}"/>
</apex:selectList>
<apex:inputField value="{!eve.AccountId}" rendered="{!source_info!='Web'}" id="list2B"/>
</apex:Column>

<apex:actionStatus id="gettingDetailnames" startText="Retrieving Detail Info..."/>

</apex:pageBlockTable>
<apex:pageBlockButtons location="Bottom">
<apex:commandButton action="{!save}" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

 


 This is the class

 

 

public with sharing class controller_test
{
List<Event> events_info = new List<Event>();
List<String> WhoIds = new List<String>();
List<Contact> Contacts_info = new List<Contact>();
public String source_info,detail_Name;
public String getSource_info()
{
return source_info;
}
public void setSource_info(String source_info)
{
this.source_info= source_info;
}
public String getDetail_Name()
{
return detail_Name;
}

public void setDetail_Name(String detail_Name)
{
this.detail_Name= detail_Name;
}
public List<SelectOption> getSource_Items()
{
List<SelectOption> options3 = new List<SelectOption>();
options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Web','Web'));
options3.add(new SelectOption('Email','Email'));
options3.add(new SelectOption('Phone','Phone'));
return options3;
}
public List<SelectOption> getDetail_Items()
{

List<SelectOption> options3 = new List<SelectOption>();
options3.add(new SelectOption('--Select--','--Select--'));
options3.add(new SelectOption('Google','Google'));
options3.add(new SelectOption('Yahoo','Yahoo'));
options3.add(new SelectOption('rediff','rediff'));
return options3;
}
public PageReference init1()
{
events_info=[Select Id,AccountId,What.Name,Who.Name,Who.Email,Who.Id from Event Where OwnerId = :UserInfo.getUserId() and order by Whoid limit 3];
for(Integer i=0;i<events_info.size();i++)
{
WhoIds.add(events_info[i].Who.Id);
}
for(Contact c:[Select Id,Email,Accountid from Contact where Id IN:WhoIds order by Id])
{
Contacts_info.add(c);
}
return null;
}
Public List<Event> getEvent_Results()
{
return events_info;
}
Public List<Contact> getContact_Results()
{
return Contacts_info;
}
public PageReference save()
{
for(Integeri=0;i<events_info.size();i++)
{
System.debug('source_info value is '+source_info);

System.debug('Detail_info value is '+detail_Name);
}
return null;
}
public PageReference Refresh()
{
PageReference pr1=new PageReference('/006/o');
system.debug('source_info value is '+source_info);
pr1.setRedirect(true);
return pr1;
}
}

 

 

 

 

 

Message Edited by renuami on 03-08-2010 11:04 AM
bob_buzzardbob_buzzard

I've had problems in the past when attempting to rerender part of a component that is iterating a list - as I recall I simply couldn't do it and ended up only allowing one entry to be changed and redrawing the whole table each time a change was made.

 

 

renuamirenuami

VoW..thanks bob that did the trick. Adding pageblocktable id .

 

But always the required action is being performed based on the source_info value selected in the last row.

 

Suppose i have 3 rows, in the first i selected Phone and in the 2nd Email and in the last Web then all the 3 rows source_info value is  being changed to Web (since it is the lasted selected value).

 

Any idea on how to overcome this?

bob_buzzardbob_buzzard

The problem here is that all of your selectlists are backed by the same variable from the controller.

 

If you need to have different variables backing elements on a per-row basis, you'll need to go the wrapper class route. Create a class that wraps up an event, plus any additional information required for the row - the selected item in this case, there may be others. Then rather than iterating a list of events, build a list of the wrapper class and iterate that in the page.

vanessenvanessen

for my case onselect and onchange do not work ,but onclick event do work.....why this??

 

here is the code:

 

<apex:page controller="KHD_CORE_ExtApplController" standardStylesheets="true" showHeader="false" sidebar="false" language="{!lang}">
<apex:form >
<apex:pageMessages />
    <table width="100%">
        <tr>
            <td style="width:100px;"><apex:outputText value="{!$ObjectType.Account.fields.Name.Label}"/></td>
            <td>
                <apex:outputPanel id="pick01">
                    <apex:selectList value="{!selectedAccountId}" size="1">
                        <apex:selectOptions value="{!Accounts}"/>
                        <apex:actionSupport event="onclick" rerender="pick02,contactDetail" status="status" />                    
                    </apex:selectList>
                 </apex:outputPanel>
            </td>
        </tr>
        <tr>
            <td><apex:outputText value="{!$ObjectType.Contact.fields.Email.Label}"/></td>
            <td>
                <apex:outputPanel id="pick02">
                    <apex:selectList value="{!selectedContactId}" size="1">
                        <apex:selectOptions value="{!Contacts}"/>
                        <apex:actionSupport event="onclick" rerender="contactDetail" status="wait" />                                            
                    </apex:selectList>
                    <apex:actionstatus id="status" startText="{!$Label.CORE_CaseWait}" />
                                        
                 </apex:outputPanel>
            </td>
        </tr>
        <tr>
            <td colspan="2">
                 <apex:outputPanel id="contactDetail" layout="block">
                    <apex:actionstatus onstart="{!Contactinfo}" id="wait" startText="{!$Label.CORE_CaseWait}" />
                               
                    <table width="100%">
                        <tr>
                            <td style="width:100px"><apex:outputText value="{!$ObjectType.Contact.fields.Title__c.Label}" /></td>
                            <td><apex:outputText value="{!selectedContact.Title__c}" /></td>
                        </tr>
                        <tr>
                            <td><apex:outputText value="{!$ObjectType.Contact.fields.Name.Label}" /></td>
                            <td><apex:outputText value="{!selectedContact.Name}" /></td>
                        </tr>
                        <tr>
                            <td><apex:outputText value="{!$ObjectType.Contact.fields.Location__c.Label}" /></td>
                            <td><apex:outputText value="{!selectedContact.Location__c}" /></td>
                        </tr>
                        <tr>
                            <td><apex:outputText value="{!$ObjectType.Contact.fields.Department.Label}" /></td>
                            <td><apex:outputText value="{!selectedContact.Department}" /></td>
                        </tr>
                        <tr>
                            <td><apex:outputText value="{!$ObjectType.Contact.fields.Phone.Label}" /></td>
                            <td><apex:outputText value="{!selectedContact.Phone}" /></td>
                        </tr>
                    </table>
                </apex:outputPanel>
            </td>
        </tr>
        <tr>
            <td></td>
            <td>
                <apex:commandButton value="{!$Label.ButtonNext}" action="{!Step1}"/>
            </td>
        </tr>
    </table>    
    </apex:form>
      
</apex:page>

Anil KamisettyAnil Kamisetty
Hi renuami

You need to add Title to the SELECT LIST and you should be all set.

<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable">

Change to...

<apex:selectList value="{!source_info}" required="true" multiselect="false" size="1" onSelect="RRTheTable" Title="TEST">

Mark this as the Answer if it addresses your question.