1

This is my public Site.

This site displays a list of records from a custom object.

If you try to do an inline edit on the 5th record you will see that you are able to do an inline edit/save successfully where as you will not be able to do an inline edit on the 3rd record .

Not sure how this inconsistency is possible as i dont have any custom logic built between these records.

My VF Page is as follows

<apex:page standardcontroller="Expense__c" extensions="ExpenseController"  sidebar="false" showHeader="true" showChat="false" recordSetVar="exp" >
<script src="../../soap/ajax/30.0/connection.js" type="text/javascript"></script>
<apex:form >

<apex:inlineEditSupport />

<apex:pageBlock title="List of Expenses">
<apex:pageBlockTable value="{!exp}" var="item" >
<apex:column value="{!item.Date__c}"/>

<apex:column value="{!item.Type__c}"/>
<apex:column value="{!item.Amount__c}"/>
<apex:column value="{!item.Comments__c}"/>
</apex:pageBlockTable>
<p>Sum of All Expenses : Rs {!SumOfAllExpenses}</p>
</apex:pageBlock>
<apex:commandButton action="{!save}" value="Save" id="theButton1" />
<!--<apex:commandButton value="Total" id="theButton2" onclick="alert('Deleting the expense...')"/>-->

</apex:form>
</apex:page>

Can someone explain this weird behavior ?

UPDATE :

public with sharing class ExpenseController
{

private ApexPages.StandardSetController sc;
public Integer SumOfAllExpenses {get; set;}


public ExpenseController(ApexPages.StandardSetController sc)
{
this.sc = sc;
SumOfAllExpenses = displayTotal();
}


public Integer displayTotal()
{

List<AggregateResult> i = [SELECT SUM(Amount__c) FROM Expense__c];
SumOfAllExpenses = Integer.valueOf(i[0].get('expr0'));
return SumOfAllExpenses;
}

public PageReference save()
{
System.debug('Before Save - Comments Value :'+(Expense__c)sc.getRecord());
sc.save();
System.debug('After Save - Comments Value :'+(Expense__c)sc.getRecord());
displayTotal();
System.debug('After Total - Comments Value :'+(Expense__c)sc.getRecord());
PageReference p = new PageReference('/apex/addExpenses');
return p;

}


}
4
  • I think you will need to post your controller class to get an answer; the page looks routine enough (assuming event="ondblclick" is the default for apex:inlineEditSupport ).
    – Keith C
    Apr 14, 2014 at 14:58
  • Hi..I have added my controller code now
    – Varun
    Apr 14, 2014 at 15:05
  • 1
    Sorry didn't notice the recordSetVar. This similar question has an accepted answer salesforce.stackexchange.com/questions/18128/….
    – Keith C
    Apr 14, 2014 at 15:12
  • Thanks Keith..it solved my issue...though it bothers me not knowing how this got resolved by making this change...thanks a bunch !!!..Please put this as answer so that i can accept the solution
    – Varun
    Apr 14, 2014 at 17:02

1 Answer 1

2

Seems like the necessary pattern to make this work is to use an apex:outputfield:

 <apex:column headerValue="Date">
     <apex:outputfield value="{!item.Date__c}"/>
 </apex:column>

This is taken from Inline edit of PageBlockTable only saving one record.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .