开发者

display records based on selection of name from picklist in salesforce

I am trying to get my hands on learning Visual force.

I have 开发者_如何学Goan object inv_c which holds invoice records and another object item_c

I have in my VF page a picklist with the object names.

If user selects inv_c then all records of inv_c are displayed if user selects item__c all records of item are displayed

Is there any way where the list would be displayed on the completion of the selection or do we have to have button to get it.

how can i achieve this in VF? any small code snippet would be wonderful

Thanks


You can do this using a JavaScript onchange event with the help of the ActionSupport Visualforce Component. Here's an example.

<!--  Page: -->  

<apex:page controller="exampleCon">
    <apex:form>
        <apex:outputpanel id="counter">
            <apex:outputText value="Click Me!: {!count}"/>
            <apex:actionSupport event="onclick" 
                                action="{!incrementCounter}" 
                                rerender="counter" status="counterStatus"/>
        </apex:outputpanel>
        <apex:actionStatus id="counterStatus" 
                           startText=" (incrementing...)" 
                           stopText=" (done)"/>
    </apex:form>
</apex:page>    

/***  Controller: ***/  

public class exampleCon {
    Integer count = 0;

    public PageReference incrementCounter() {
            count++;
            return null;
    }

    public Integer getCount() {
        return count;
    }
}

In your case the actionSupport component would be a child of your selectRadio component i.e.

<apex:selectRadio value="{!selection}">
  <apex:selectOptions value="{!items}"/>
  <apex:actionSupport event="onchange" .... />
</apex:selectRadio>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜