I have a VF page in that I am having a List which has picklist field called "Status", values named "open" and "complete". When we select the picklist value "Complete" then the record should move to the another list called "history" which empty by initial. Kindly tell how to get the picklist value.Thanks in advanced
Code:
public with sharing class sample {
public Integer numberOfRowToRemove1 { get; set; }
public List<Account> list1 { get; set; }
public List<Account> list2 { get; set; }
public string temp{get;set;}
public sample() {
list1 = [select id,name,accountnumber from Account limit 2];
list2 = [select id,name,accountnumber from Account limit 3];
}
public List<selectOption> getitems() {
List<selectoption> options=new List<selectoption>();
options.add(new selectoption('Complete','Complete'));
options.add(new selectoption('Open','Open'));
return options;
}
public PageReference showdata() {
if(temp=='Complete') {
list2.add(0,list1.get(numberOfRowToRemove1));
list1.remove(numberOfRowToRemove1);
}
return null;
}
}
Page:
<apex:page controller="sample" >
<apex:form >
<apex:variable value="{!0}" var="rowNumber1" />
<apex:outputPanel id="panelWithVar">
<apex:variable value="{!0}" var="rowNumber1" />
</apex:outputPanel>
**<apex:actionFunction name="find" action="{!showdata}"/>**
<apex:pageBlock id="table1">
<apex:dataTable value="{!list1}" var="a" columnswidth="100px,100px" cellpadding="3" columns="4" border="1" width="500px" bgcolor="#f5dcef" rowClasses="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" />
<apex:column value="{!a.AccountNumber}" headerValue="Number" width="100"/>
<apex:column headerClass="Status">
**<apex:selectList id="selected_list" value="{!temp}" required="false" size="1" onchange="find();">**
<apex:selectOptions value="{!items}"/>
<!--<apex:selectOption itemvalue="None" itemLabel="--None--"/>
<apex:selectOption itemvalue="complete" itemLabel="complete"/>
<apex:selectOption itemvalue="Open" itemLabel="Open"/>-->
<!--<apex:actionSupport event="onchange" reRender="Details,panelWithVar,table1" action="{!find}" onsubmit="checkAll(this)"/>-->
<apex:param name="p1" value="{!rowNumber1}" assignTo="{!numberOfRowToRemove1}"/>
</apex:selectList>
<apex:variable var="rowNumber3" value="{!rowNumber1 + 1}" />
</apex:column>
</apex:dataTable>
</apex:pageBlock>
<apex:pageBlock id="Details">
<apex:pageBlockSection >
<apex:panelGroup >
<apex:dataTable value="{!list2}" var="a" columnswidth="50px,50px" cellpadding="4" border="1" >
<apex:column value="{!a.Name}" headerValue="Customer Name" width="100"/>
<apex:column value="{!a.AccountNumber}" headerValue="Address" width="100"/>
<apex:column headerClass="Status">
<apex:selectList id="selected_list" value="{!temp}" required="false" size="1">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
</apex:column>
</apex:dataTable>
</apex:panelGroup>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>