• supriya Gore
  • NEWBIE
  • 45 Points
  • Member since 2016

  • Chatter
    Feed
  • 1
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 4
    Replies
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}
Hi,

i am new to apex class , i am getting below errors as well as i put the comments with errors.
Public class fetchdisplayrecords
{
public Contact Con{get; set;}
public string selectedItemValue{get;set;}
public id resc{get;set;}
public fetchdisplayrecords(ApexPages.StandardController controller)
 {
   //acc = [SELECT Name, AccountNumber FROM Account limit 5];
 }
     public List<selectoption> getitems()
     {
     List<Selectoption> opts = new List<Selectoption>();
        opts.add(new selectoption('','--None--'));  // Compile Error: Non-void method might not return a value or might have statement after a return statement.
     }
     
     
     

}



kindly help me on this. i appricated!
component:
<aura:component implements="force:appHostable" controller="FetchRegistrations" >
    <aura:attribute name="reg" type="Registration__c[]"/>
    <ui:button label="Get Registrations" press="{!c.myAction}"/>
    <aura:iteration var="r" items="{!v.reg}" >
    <p>{!r.name}</p>
    </aura:iteration>
</aura:component>


Controller:
({
   myAction : function(component, event, helper) {
        var action = component.get("c.getAllregistrations");
        action.setCallback(this, function(response){
            var name = response.getState();
            if (name === "SUCCESS") {
                component.set("v.reg", response.getReturnValue());
            }
        });
     $A.enqueueAction(action);
    }
})

Apex:
global with sharing class FetchRegistrations {
@auraEnabled
    public static List<Registration__c> getAllregistrations()
    {
     List<Registration__c> reg=new LIST<Registration__c>();  
        reg=[select id,name,Email__c from Registration__c];
        return reg;
    } 
    public Registration__c getSelectedregistrations(Id id)
    {    
      Registration__c  reg=[select id,name,Email__c from Registration__c where id=:id];
        return reg;
    } 
   
}