+ Start a Discussion
Sayan Mukherjee 11Sayan Mukherjee 11 

adding multiple row in vf page dynamically

I have a vf page where i want to add rows every time "add  row" button is clicked..but i am facing some error..when a new row is created previous row's values are automatically copied ..
here is my controller class-
public class SayanTest{
public Service_Type__c acc{get;set;}
public Service_Request__c sr{get;set;}
public Service_Line_Item__c slt;
public List<Service_Line_Item__c> cont{get;set;}
//public List<Work_Order__c> wo{get;set;}
public List<Work_Order__c> wod=new List<Work_Order__c>();
public List<Service_Type__c > accl{get;set;}
//public List<Service_Line_Item__c> cont1{get;set;}
public Boolean showBank{get;set;}
public Boolean showCard{get;set;}
public Boolean showOther{get;set;}
public Boolean showTransfer{get;set;}
public boolean displayPopup {get; set;} 
public boolean flag1 {get;set;}
public String selected {get;set;}
public Boolean tenkservice{get;set;}
public Boolean engineoiltype{get;set;}
public Boolean clutchtype{get;set;}
public Boolean tyretype{get;set;}
public Boolean fanbelt{get;set;}
public Boolean coolant{get;set;}
public Boolean newRow{get;set;}
public Boolean estimation{get;set;}
public Decimal engrate{get;set;}
public Decimal clutchrate{get;set;}
public Decimal tyrerate{get;set;}
public Decimal fanrate{get;set;}
public Decimal coolrate{get;set;}
public Decimal englbr{get;set;}
public Decimal clutchlbr{get;set;}
public Decimal tyrelbr{get;set;}
public Decimal fanlbr{get;set;}
public Decimal coollbr{get;set;}
public Decimal allRateSpare{get;set;}
public Decimal allRateLabour{get;set;}
public Decimal sum{get;set;}
public Decimal count{get;set;}
public Decimal total{get;set;}
public Boolean tyrecount;
public Boolean engcount;
public Boolean clutchcount;
public Boolean fanbeltcount;
public Boolean coolantcount;
public Boolean oilfiltertype{get;set;}
public Decimal s;
public decimal engspare;
public Decimal englabour;
public Decimal engqty{get;set;}
public Decimal englbrqty{get;set;}
public Decimal clutchspare;
public Decimal clutchlabour;
public Decimal clutchspareqty{get;set;}
public Decimal clutchlbrqty{get;set;}
public Decimal tyrespare;
public Decimal tyrelabour;
public Decimal tyrespareqty{get;set;}
public Decimal tyrelbrqty{get;set;}
public Decimal fanbeltspare;
public Decimal fanbeltlabour;
public Decimal fanbeltspareqty{get;set;}
public Decimal fanbeltlbrqty{get;set;}
public Decimal coolantspare;
public Decimal coolantlabour;
public Decimal coolantspareqty{get;set;}
public Decimal coolantlbrqty{get;set;}
public Decimal allspare;
public Decimal alllabour;
public Decimal allspareqty{get;set;}
public Decimal alllbrqty{get;set;}
public Decimal oilfilterspareqty{get;set;}
public Decimal oilfiltersparerate{get;set;}
public Decimal oilfilterlabourqty{get;set;}
public Decimal oilfilterlabourrate{get;set;}
public Integer jobcount;
public Integer i=0;
public SayanTest(ApexPages.StandardController controller) { 
 acc= (Service_Type__c)controller.getRecord();
showBank = false;
      showCard = false;
      showTransfer = false;
    acc = new Service_Type__c ();
    cont = new List<Service_Line_Item__c>();
    accl=new List<Service_Type__c >();
   // wo=new List<Work_Order__c>();
   //wod=new Work_Order__c();
    //cont1= new List<Service_Line_Item__c>();
   // slt=new Service_Line_Item__c();

public PageReference  AddRow(){
//Service_Type__c  s=new Service_Type__c ();
 Service_Line_Item__c sli=new Service_Line_Item__c();
    return null;


bharath kumar 52bharath kumar 52

Try commenting add row in the constructor. In my opinion you are trying to create a new line item on click of a button where you will call add row.
Check this link : http://www.forcetree.com/2015/03/dynamically-addremove-rows-from-table.html
Let me know if either of them solve the issue.


Sayan Mukherjee 11Sayan Mukherjee 11
yah..the requirement is like that whenever the add row button clicked a new row will open which will create a new line item..