You need to sign in to do that
Don't have an account?
Soundar Rajan Ponpandi
Remove Records From wrapper List
Hi Expert,
Now i am displaying selected records to Pageblock2 . Though selected records are don't need to show in PageBlock1. kindly Check the below Image For information.
**************** Apex *******************
*********************VF Page ***********************
**********Sample output ***********
Special Thanks In Advance !!!!
Regards,
Soundar
Now i am displaying selected records to Pageblock2 . Though selected records are don't need to show in PageBlock1. kindly Check the below Image For information.
**************** Apex *******************
public class OppDisplaySelectedContrl { public List<oppWrapper> listOppWrap{get;set;} Public List<Opportunity> listOfSelectedOpp{get;set;} Public List<Opportunity> listOfSelectedOpp2{get;set;} Set<Integer> st = New Set<Integer>(); public OppDisplaySelectedContrl(){ listoppWrap = new List<oppWrapper>(); searchrecord(); } public void searchrecord(){ listOppWrap.clear(); for(Opportunity opp : [Select id,name,stageName,amount, CloseDate From Opportunity Limit 5]){ listOppWrap.add(New OppWrapper(opp)); System.debug('Opportunity list' + opp ); } } public void addToGrid(){ listOfSelectedOpp = New List<Opportunity>(); listOfSelectedOpp.clear(); for(OppWrapper OppWrapObj : listOppWrap){ if(OppWrapObj.selected == True){ listOfSelectedOpp.add(OppWrapObj.wrapOpp); } } } public void closedWon(){ for(Opportunity opp : listOfSelectedOpp){ opp.StageName = 'Closed Won'; } update listOfSelectedOpp; searchrecord(); } public void closedLost(){ for(Opportunity opp : listOfSelectedOpp){ opp.StageName = 'Closed Lost'; } update listOfSelectedOpp; searchrecord(); } public class OppWrapper{ public boolean selected{get;set;} public Opportunity wrapOpp{get;set;} public OppWrapper(Opportunity opp){ selected = false; wrapOpp = opp; } } }
*********************VF Page ***********************
<apex:page controller="OppDisplaySelectedContrl"> <apex:form > <apex:pageBlock title="Opportunity" id="pb1"> <apex:pageBlockSection title="All Opportunity" columns="1"> <apex:pageBlockTable value="{!listOppWrap}" var="oppWrap" > <apex:column > <!--<apex:inputCheckbox value="Select"/> --> </apex:column> <apex:column headerValue="Select"> <apex:inputCheckbox value="{!oppWrap.selected}" /> </apex:column> <apex:column value="{!oppWrap.wrapOpp.name}"/> <apex:column value="{!oppWrap.wrapOpp.StageName}"/> <apex:column value="{!oppWrap.wrapOpp.closeDate}"/> <apex:column value="{!oppWrap.wrapOpp.amount}"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Add To Grid" action="{!addToGrid}"/> </apex:pageBlockButtons> </apex:pageBlock> <apex:pageBlock title="Selected opportunity" id="pb2"> <apex:pageBlockSection columns="1"> <apex:pageBlockTable value="{!listOfSelectedOpp}" var="selectedOpp" > <apex:column value="{!selectedOpp.name}" headerValue="Opportunity Name"/> <apex:column value="{!selectedOpp.StageName}" headerValue="Stage"/> <apex:column value="{!selectedOpp.closeDate}" headerValue="Closed Date"/> <apex:column value="{!selectedOpp.Amount}" headerValue="Amount"/> </apex:pageBlockTable> </apex:pageBlockSection> <apex:pageBlockButtons > <apex:commandButton value="Closed Won" action="{!closedWon}"/> <apex:commandButton value="Closed Lost" action="{!closedLost}" /> </apex:pageBlockButtons> </apex:pageBlock> </apex:form> </apex:page>
**********Sample output ***********
Special Thanks In Advance !!!!
Regards,
Soundar
======
replace this function with below code
All Answers
======
replace this function with below code
Your Code is Working Perfectly what i am expecting , and right now i need some changes in that code !
1. Selected record's removed from pageblockTable1.
2. Now it's added in pageblockTable2.
3.And again i Like to select and display from pageblocktable1 to pageblocktable2 . for example
initially i was selected 1 record and click the addToGrid Button and again i like to select 2 records . now 3 records need to be show in pageblockTable.
Could you please advise me how it's possible ...
Thanks in advance..
Regards,
Soundar.
Thanks for your quick response. Can you please advise me for above comment please
Note:
1. Selected record's removed from pageblockTable1.
2. Now it's added in pageblockTable2.
3.And again i Like to select and display from pageblocktable1 to pageblocktable2 . for example
initially i was selected 1 record and click the addToGrid Button and again i like to select 2 records . now 3 records need to be show in pageblockTable.
Regards.
SOUNDAR
I solved above comments by myself . Even it's Possible by both of your help (Mr. vijayabhaskarareddy & Mr. bob_buzzard).
I make some changes in the code .
Regards,
Soundar.
How i can do this?