You need to sign in to do that
Don't have an account?
SFDC Dummy
How to Use two Page BlockTable in single Page Block
Hi
I have created a Vf page .but i am unable to use two page block table in single page block.how its possible can any body tell me
I have created a Vf page .but i am unable to use two page block table in single page block.how its possible can any body tell me
<apex:page tabstyle="Account" showHeader="false" sidebar="false" Controller="ManageListController1"> <apex:define name="body"> <div style="width:900px;margin: 10px auto 10px auto;background-color:Gray;"> <apex:form > <apex:pageBlock title="Bank Book Entry:"> <apex:pageBlockSection columns="2"> <apex:pageBlockTable value="{!wrappers1}" var="wrapper1" id="wtable1"> <apex:column headerValue="Date" style="background:gray;"> <apex:outputText value="{!wrapper1.Txn_Date__c}"/> </apex:column> </apex:pageBlockTable> <div style="width:500px;margin: 10px auto 10px auto;"> <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable"> <apex:column headerValue="Ident" style="background:gray;"> <apex:outputText value="{!wrapper.ident}"/> </apex:column> <apex:column headerValue="Master Code" style="background:gray;"> <apex:inputField value="{!wrapper.acc.Entries_Code__c}"/> </apex:column> <apex:column headerValue="Amount" style="background:gray;"> <apex:inputField value="{!wrapper.acc.Amount__c}"/> </apex:column> <apex:column headerValue="Narration" style="background:gray;"> <apex:inputField value="{!wrapper.acc.Narration__c}"/> </apex:column> <apex:column headerValue=""> <apex:commandButton value="Enter" action="{!addRows}" rerender="wtable" style="background:pink" > <apex:param name="addCount" value="1" assignTo="{!addCount}"/> </apex:commandButton> </apex:column> <apex:column headerValue="Action"> <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable" style="background:Red"> <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/> </apex:commandButton> </apex:column> </apex:pageBlockTable> </div> <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable" style="width:100px;margin: 10px auto 10px auto;"> <apex:param name="addCount" value="5" assignTo="{!addCount}"/> </apex:commandButton> <apex:commandButton value="Save" action="{!save}" style="width:100px;margin: 10px auto 10px auto;"/> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </div> </apex:define> </apex:page>
public class ManageListController1 { public ManageListController1(ApexPages.StandardController controller) { } public List<AccountWrapper> wrappers {get; set;} public List<AccountWrapper> wrappers1 {get; set;} public static Integer toDelIdent {get; set;} public static Integer addCount {get; set;} private Integer nextIdent=0; public ManageListController1() { wrappers=new List<AccountWrapper>(); Wrappers1=new List<AccountWrapper>(); for (Integer idx=0; idx<1; idx++) { wrappers.add(new AccountWrapper(nextIdent++)); wrappers1.add(new AccountWrapper(nextIdent++)); } } public void delWrapper() { Integer toDelPos=-1; for (Integer idx=0; idx<wrappers.size(); idx++) { if (wrappers[idx].ident==toDelIdent) { toDelPos=idx; } } if (-1!=toDelPos) { wrappers.remove(toDelPos); } } public void addRows() { for (Integer idx=0; idx<addCount; idx++) { wrappers.add(new AccountWrapper(nextIdent++)); } } public PageReference save() { List<BankBook__c> accs=new List<BankBook__c>(); for (AccountWrapper wrap : wrappers) { accs.add(wrap.acc); } insert accs; return new PageReference('/' + Schema.getGlobalDescribe().get('BankBook__c').getDescribe().getKeyPrefix() + '/o'); } public pageReference parentPage () { return new pageReference('/apex/Receivables'); } public class AccountWrapper { public BankBook__c acc {get; private set;} public Integer ident {get; private set;} public AccountWrapper(Integer inIdent) { ident=inIdent; acc=new BankBook__c(); } } }
We can use multiple pageblocktables in single pageblock without any limitation. Can you please share compilation error ?
Thanks & Cheers,
Jigar(pateljb90@gmail.com)
Please replace your visualforce page code with below code.
Thanks & Cheers,
Jigar(pateljb90@gmail.com)
Your compilation error is because of property not available in you wrapper class. I think you are trying to user Txn_Date__c field of BankBook__c object.
Replace below code
With
It will resolve compilation error.
Thanks & Cheers,
Jigar(pateljb90@gmail.com)