You need to sign in to do that
Don't have an account?
Rakesh M
how to add row?
Admin Requirement:
When I click on add button one more InvoicelineItem row should be added to pageBlockTable.
Please help me in achieving this functionality.
Code:
public class InvoiceLineItem {
public string ProdName{set;get;}
public decimal Quantity{set;get;}
public decimal price{set;get;}
public string tax{set;get;}
public string productfamily{set;get;}
public list<InvoiceLineItem__c> Ili{set;get;}
public InvoiceLineItem__c I{set;get;}
public InvoiceLineItem(){
Ili= [select ProductName_c,Quantityc,Pricec,productc from InvoiceLineItem_c];
}
public void Add(){
Ili = new list<InvoiceLineItem__c>();
I = new InvoiceLineItem__c();
I.ProductName__c=ProdName;
I.Quantity__c=Quantity;
I.Price__c=Price;
I.Product__c=productfamily;
Ili.add(I);
insert Ili;
}
}
<apex:page controller="InvoiceLineItem">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Ili}" var="a">
<apex:column headerValue="ProdName">
<apex:inputText value="{!a.ProductName__c}"/>
</apex:column>
<apex:column headerValue="Quantity">
<apex:inputText value="{!a.Quantity__c}"/>
</apex:column>
<apex:column headerValue="Price">
<apex:inputText value="{!a.Price__c}"/>
</apex:column>
<apex:column headerValue="ProductFamily">
<apex:inputText value="{!a.Product__c}"/>
</apex:column>
<apex:column >
<apex:commandButton value="Add" action="{!Add}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks in advance.
When I click on add button one more InvoicelineItem row should be added to pageBlockTable.
Please help me in achieving this functionality.
Code:
public class InvoiceLineItem {
public string ProdName{set;get;}
public decimal Quantity{set;get;}
public decimal price{set;get;}
public string tax{set;get;}
public string productfamily{set;get;}
public list<InvoiceLineItem__c> Ili{set;get;}
public InvoiceLineItem__c I{set;get;}
public InvoiceLineItem(){
Ili= [select ProductName_c,Quantityc,Pricec,productc from InvoiceLineItem_c];
}
public void Add(){
Ili = new list<InvoiceLineItem__c>();
I = new InvoiceLineItem__c();
I.ProductName__c=ProdName;
I.Quantity__c=Quantity;
I.Price__c=Price;
I.Product__c=productfamily;
Ili.add(I);
insert Ili;
}
}
<apex:page controller="InvoiceLineItem">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!Ili}" var="a">
<apex:column headerValue="ProdName">
<apex:inputText value="{!a.ProductName__c}"/>
</apex:column>
<apex:column headerValue="Quantity">
<apex:inputText value="{!a.Quantity__c}"/>
</apex:column>
<apex:column headerValue="Price">
<apex:inputText value="{!a.Price__c}"/>
</apex:column>
<apex:column headerValue="ProductFamily">
<apex:inputText value="{!a.Product__c}"/>
</apex:column>
<apex:column >
<apex:commandButton value="Add" action="{!Add}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Thanks in advance.
Try changing your code as below in constructor Thanks and Regards
Sandhya
Please go through the below blog which would help u in attaining the above functionality:
http://salesforceworld4u.blogspot.ca/2014/01/addremove-functionality-in-vf-page-for.html
Regrds,
Rabi