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
RavitejaRaviteja 

how to build empty table in vf & need to insert values into that table (manually)

how to build empty table in vf & need to insert values into that table (manually)

Eugene PozniakEugene Pozniak

If you are going to create new sObject using values of the table, use following as example:

 

controller:

public class emptyTableController {
	public yourSObject fakeSObject { get; set; }
	
	public emptyTableController() {
		fakeSObject = new yourSObject();
	}
}

 

page:

<apex:page controller="emptyTableController">
	<apex:form>
		<apex:pageBlock>
			<apex:pageBlockSection columns="enterYourSize">
				<apex:pageBlockSectionItem>
					<apex:inputField value="fakeSObject.APIFieldName" />
				</apex:pageBlockSectionItem>
				
				<!-- Repeat for all fields that you need -->
			<apex:pageBlockSection>
		<apex:pageBlock>
	<apex:form>
</apex:page>

 

 If this table will not contain fields of sObject, use attributes like: <apex:inputText />, <apex:inputHidden />. For more detail read documentation about Standard Component Reference.

Chamil MadusankaChamil Madusanka

Are you looking for as follow approach? Try this solution.

 

<apex:page controller="manageScheduleController2" >
   
    
    <apex:form >
    
    
        <apex:pageBlock id="result">
            <apex:pageBlockTable value="{!ContactList}" var="con">
                 <apex:column value="{!con.Email}"/>
            <apex:column value="{!con.Account}"/>
                <apex:column value="{!con.Description}"/>
                <apex:column value="{!con.Phone}"/>
      
                
            </apex:pageBlockTable>
        </apex:pageBlock>
        
        <apex:commandButton value="Add Contact" action="{!addContact}" reRender="result"/>
        
    </apex:form> 
 
</apex:page>

 

public with sharing class manageScheduleController2{

    public List<Contact> ContactList { get; set; }
    public Contact cont{get;set;}

    public manageScheduleController2()
    {            
        ContactList = new List<Contact>();
    } 
    
    public void addContact()
    {
       cont = new Contact();
       cont.Email = 'chamil.madusanka@gmail.com';
       cont.Description = 'I\'m a Salesforce Developer';
       cont.Phone= '947777777777';
      ContactList.add(cont);
       
    }
   

}

 

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.