You need to sign in to do that
Don't have an account?
sava action not working in inline editing
Hi,
i am developing in line editing exactly what apex:enhencedlist do.but the save button is not working after editing.below is my code,please check and kindly rectify the error as soon as possible.thanks in advance.
visual force page:
<apex:page controller="Fund_Type_Controller">
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" />
<apex:stylesheet value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-lightness/jquery-ui.css" />
<link rel="stylesheet"
href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!-- <script>
function highlightElem(elem){
$('tr').removeClass('ui-state-highlight');
$(elem).addClass('ui-state-highlight');
}
</script> -->
<!-- check all columns demo page -->
<apex:form >
<apex:pageblock title="Fund Type" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Search" action="{!filterRecord}"
reRender="thePanelWrapper" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2">
<apex:inputField id="id3"
value="{!SearchCriteria.FUND_TYPE_NAME__c}" />
<apex:inputField id="id2" value="{!SearchCriteria.FUND_TYPE__c}" />
<apex:inputField id="id4" value="{!SearchCriteria.SHORT_CODE__c}" />
<apex:inputField id="id5" value="{!SearchCriteria.ACCRUAL_RATE__c}" />
<apex:inputField id="id6" value="{!SearchCriteria.PLAN_REQ_FLAG__c}" />
<apex:inputField id="id7"
value="{!SearchCriteria.DEAL_DATE_REQ_FLAG__c}" />
<apex:inputField id="id8"
value="{!SearchCriteria.DEAL_CUST_REQ_FLAG__c }" />
</apex:pageBlockSection>
</apex:pageblock>
<apex:outputPanel id="thePanelWrapper">
<apex:pageblock id="myblock" rendered="{!rend}">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!tosave}" id="saveButton" />
</apex:pageBlockButtons>
<apex:pageblocktable value="{!Contacts}" var="c">
<!-- onRowClick="highlightElem(this) -->
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox onclick="selectCheckboxes(this,'inputId')" />
</apex:facet>
<apex:inputCheckbox value="{!c.selected}" id="inputId">
<apex:actionSupport event="onclick" action="{!getSelected}"
reRender="hiddenBlock">
<apex:param name="para" value="{!c.con.id}" assignTo="{!para}" />
</apex:actionSupport>
</apex:inputCheckbox>
</apex:column>
<apex:column >
<apex:facet name="header">
<apex:outputText value="Action"></apex:outputText>
</apex:facet>
<apex:commandLink title="Edit">Edit</apex:commandLink> | <apex:commandLink title="Delete">Delete</apex:commandLink>
</apex:column>
<apex:column value="{!c.con.FUND_TYPE__c}" id="fname">
<apex:facet name="header">
<apex:commandLink value="Fund Type{!IF(sortExpression=='FUND_TYPE__c',IF(sortDirection='ASC','▼','▲'),'')}">
<apex:param value="FUND_TYPE__c" name="column"
assignTo="{!sortExpression}"></apex:param>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:column value="{!c.con.FUND_TYPE_NAME__c}">
<apex:facet name="header">
<apex:commandLink value="Fund Type Name{!IF(sortExpression=='FUND_TYPE_NAME__c',IF(sortDirection='ASC','▼','▲'),'')}">
<apex:param value="FUND_TYPE_NAME__c" name="column"
assignTo="{!sortExpression}"></apex:param>
</apex:commandLink>
</apex:facet>
</apex:column>
<apex:inlineEditSupport event="ondblClick" showOnEdit="saveButton" />
</apex:pageblocktable>
</apex:pageblock>
</apex:outputPanel>
<apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>
</apex:form>
<script type="text/javascript">
function selectCheckboxes(inpt,receivedInptID)
{
var inputCheckBox = document.getElementsByTagName("input");
for(var i=0; i<inputCheckBox.length; i++)
{
if(inputCheckBox[i].id.indexOf(receivedInptID)!=-1){
inputCheckBox[i].checked = inpt.checked;
}
}
}
</script>
<script type="text/javascript">
function openWin(ReceiveInputID){
var inputValue = document.getElementById(ReceiveInputID).innerHTML;
console.log(ReceiveInputID,inputValue)
$("#textfield").val(inputValue)
$("#dialog").dialog({
buttons: {
'Save': function saver() {},
'Cancel': function() {$( this ).dialog( "close" );}
}});
}
</script>
<body>
<div id="dialog" title="Fund Type" style="display: none">Fund
Name:<input type="text" id="textfield" /></div>
</body>
</apex:page>
Controller:-
Public with sharing class Fund_Type_Controller {
Public List<contactwrapper> contactList {get;set;}
public TP_TPM_Fund_Type_TBL__c SearchCriteria{get;set;}
public TP_TPM_Fund_Type_TBL__c contact{get;set;}
public Id Id{get;set;}
List<TP_TPM_Fund_Type_TBL__c> selectedContacts = new List<TP_TPM_Fund_Type_TBL__c>();
public string message;
public Boolean rend { get; set; }
public String para{get;set{ para = value;}}
Public Fund_Type_Controller(){
SearchCriteria=new TP_TPM_Fund_Type_TBL__c();
TP_TPM_Fund_Type_TBL__c contact = new TP_TPM_Fund_Type_TBL__c();
rend = false;
}
public PageReference filterRecord(){
rend=true;
return null;
}
public String sortExpression{
get{
return sortExp;}
set{
if (value == sortExp)
sortDirection = (sortDirection == 'ASC')? 'DESC' : 'ASC';
else
sortDirection = 'ASC';
sortExp = value;}}
public String getSortDirection(){
if (sortExpression == null || sortExpression == '')
return 'ASC';
else
return sortDirection;}
private String sortDirection = 'ASC';
private String sortExp = 'name';
Public List<contactwrapper> getContacts(){
contactList = New List<contactwrapper>();
string sortFullExp = sortExpression + ' ' + sortDirection;
String wcVal=SearchCriteria.FUND_TYPE__c + '%';
if (SearchCriteria.FUND_TYPE__c!=NULL){
for(TP_TPM_Fund_Type_TBL__c c:(Database.query('Select FUND_TYPE__c,FUND_TYPE_NAME__c From TP_TPM_Fund_Type_TBL__c where FUND_TYPE__c like :wcVal order by ' + sortFullExp + ' limit 1000'))){
contactList.add(New contactwrapper(c));}
return contactList;}
else{
for(TP_TPM_Fund_Type_TBL__c c:(Database.query('Select FUND_TYPE__c,FUND_TYPE_NAME__c From TP_TPM_Fund_Type_TBL__c order by ' + sortFullExp + ' limit 1000'))){
contactList.add(New contactwrapper(c));}
return contactList;}}
public PageReference getSelected() {
System.debug('param valueeeeeeeee'+para);
selectedContacts.clear();
for(contactwrapper conwrapper: contactList)
if(conwrapper.selected == true)
selectedContacts.add(conwrapper.con);
return null;}
public List<TP_TPM_Fund_Type_TBL__c> GetSelectedContacts(){
if(selectedContacts.size()>0)
return selectedContacts;
else
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
return null;}
//save action methode after editing
public PageReference tosave() {
if(selectedContacts.size()>0){
update selectedContacts;
PageReference FundType=new PageReference('/apex/FundType');
FundType.setRedirect(true);
return FundType;}
else{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Please select at least one Contact.'));
return null;}}
Public class contactwrapper{
Public TP_TPM_Fund_Type_TBL__c con{get;set;}
Public Boolean selected{get;set;}
Public contactwrapper(TP_TPM_Fund_Type_TBL__c c){
con = c;
selected = false;}}
}