You need to sign in to do that
Don't have an account?
Sonam Patil
AddROW functionality in Custom Settings
Hi,
In the code below, I could get all the records from the database, but I want to add the row. When I click on ADD button the row is not getting add.
The object is Custom Setting Object. Will addRow functionally work for Custom Settings?
Can anyone Please help me.
Thanks in Advance.
<apex:page controller="Setting">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="ADD" action="{!addRow}"/>
<apex:commandButton value="Fetch" action="{!fetch}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!codes}" var="c">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.Code__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
-------------------------------------------------------------------------------------------------------------
public with sharing class Setting {
public Integer x=0;
countryCode__c ce = new CountryCode__c();
public PageReference addRow() {
CountryCode__c cd = new CountryCode__c();
codes.add(cd);
x++;
return null;
}
public PageReference save() {
return null;
}
public List<CountryCode__c> codes { get; set; }
public Setting(){
codes = new List<CountryCode__c>();
codes.add(ce);
}
public void fetch(){
// codes = new List<CountryCode__c>();
Map<String,CountryCode__c> allcode = countryCode__c.getAll();
codes = allcode.values();
}
}
In the code below, I could get all the records from the database, but I want to add the row. When I click on ADD button the row is not getting add.
The object is Custom Setting Object. Will addRow functionally work for Custom Settings?
Can anyone Please help me.
Thanks in Advance.
<apex:page controller="Setting">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="ADD" action="{!addRow}"/>
<apex:commandButton value="Fetch" action="{!fetch}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!codes}" var="c">
<apex:column value="{!c.Name}"/>
<apex:column value="{!c.Code__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
-------------------------------------------------------------------------------------------------------------
public with sharing class Setting {
public Integer x=0;
countryCode__c ce = new CountryCode__c();
public PageReference addRow() {
CountryCode__c cd = new CountryCode__c();
codes.add(cd);
x++;
return null;
}
public PageReference save() {
return null;
}
public List<CountryCode__c> codes { get; set; }
public Setting(){
codes = new List<CountryCode__c>();
codes.add(ce);
}
public void fetch(){
// codes = new List<CountryCode__c>();
Map<String,CountryCode__c> allcode = countryCode__c.getAll();
codes = allcode.values();
}
}
I have checked your code and row is adding.If you want it as inputs then please change your visual force page as below.
Hope this helps you!
If this helps you please mark it as solved.
Thanks and Regards
Sandhya