+ Start a Discussion
MundMund 

need help in saving data by making a dynamic visual force datatable

Hi All,

 

In my visual force page registration page, , i have to save the fields displayed in 3 objects namely

1. User

2. medical license

3. Location

 

In my visual force page, I need to show multiple location values in the format ( basically columns appearing like rows).

There should be a custom link on the top with a (+) symbol and on clicking on it, another instance of the location containing office name, address city should be shown and when clicked on (-) symbol, it should remove the latest one added. Please help me with the code. I am really in urgent need of this code sample. Please Help. Thanks Mumd

 

Office location object which needs to be displayed on visual force page and saved in the object ( office location )

 

office name :

 

address :

 

City :

 

All of them are input fields on the visual force page.

 

 

Please help me with the code

 

Cheers

Mund

jd123jd123

Hi

 

i think it will help full you

 

public List<Office_Name> ifList{set;get;}

 

 

Iist<Office_Name__c> ofList=new <Office_Name__c();

 

public pagereference addRow()

  {

     

    Office_Name on=new Office_Name();

    ofList.add(on);

  }

 

this is delete example 

 

<apex:page controller="removerowfrompageblocktable" >

<apex:form >

  <apex:pageBlock >

 

      <apex:pageBlockTable id="dttable" value="{!con}" var="c">

      <Apex:column ><apex:facet name="header">Action</apex:facet><apex:commandLink action="{!removecon}" reRender="dttable" ><apex:param assignTo="{!conid}" value="{!c.id}" name="assignvalue" /> Remove Row</apex:commandLink> </Apex:column>

        <Apex:column ><apex:facet name="header">Name</apex:facet>{!c.name}</Apex:column>

      <Apex:column ><apex:facet name="header">Email</apex:facet>{!c.Email}</Apex:column>

      </apex:pageBlockTable>

 

  </apex:pageBlock>

  </apex:form>

</apex:page>

 

------------ Apex controller-----------------

 

public class removerowfrompageblocktable

{

    public list<contact>con{get;set;}

    public string conid{get;set;}

    public integer removepos{get;set;}

    public removerowfrompageblocktable ()

    {

        con=[select id,name,email from contact limit 1000];

    }

    

    public void removecon()

    {

        if(con.size()>0)

        {

            for(Integer i=0;i<con.size();i++)

            {

                if(con[i].id==conid)

                {

                    removepos=i;

                }

            }

            con.remove(removepos);

           

        }

    }

   

}

 

 http://salesforcesource.blogspot.in/2009/09/edit-and-delete-command-for-your.html

 

If your question is resolved please mark it as accept as a solution if not please let me know