You need to sign in to do that
Don't have an account?
Swamy P
How to Show Grand Total by the dynamically added Rows in Page Block Table
Hello Everyone,
I wanted to show a Grand Total Value by adding all of the Total Values which is appearing in the below image. All these are ROWS are added dynamically.
I've already implemented some of the code but it is not showing Correct/Exact values. Please provide your valuable solutions.
I wanted to show a Grand Total Value by adding all of the Total Values which is appearing in the below image. All these are ROWS are added dynamically.
I've already implemented some of the code but it is not showing Correct/Exact values. Please provide your valuable solutions.
This issue has been resolved now. Below is the code which I've created for the total Calculation. I hope this may help others!!!!
function calculate_finalValue() {
var total_Tcv = 0;
var GranToral=0;
$("[id$='kpt']").each(function(){ // kpt will be the ID of an Total Field.
var values = parseInt($(this).val().trim());
if(!isNaN(values)){
GranToral+=values;
}
});
$("[id$='grndt']").val(GranToral); // grndt is an "Grand Total:" of my field.
}
<apex:column headerValue="Total">
<apex:inputText value="{!e1.total}" id="kpt" style="width:40px;" html-readonly="true" onchange="calculate_finalValue();"/>
<apex:facet name="footer">
Grand Total:<apex:inputtext id="grndt" value="{!grandTotalVal}" style="width:40px;" html-readonly="true"/>
</apex:facet>
</apex:column>
All Answers
The Grand total can be dynamically calculated using Formula field.
Please try using formula field adding all the values (api field name).
Hope this will help you.
Thanks
Can you mention what exactly we can add to get the result. This functionality is in VF Page.
If you need display on VF page, we need to implement this logic via Javascript using ".each" function. I have tried the same in my org, will provide you the snapshot. Please check below and let me know if you face any issues.
Thanks,
Gaurav
Email: gauravgarg.nmims@gmail.com
This issue has been resolved now. Below is the code which I've created for the total Calculation. I hope this may help others!!!!
function calculate_finalValue() {
var total_Tcv = 0;
var GranToral=0;
$("[id$='kpt']").each(function(){ // kpt will be the ID of an Total Field.
var values = parseInt($(this).val().trim());
if(!isNaN(values)){
GranToral+=values;
}
});
$("[id$='grndt']").val(GranToral); // grndt is an "Grand Total:" of my field.
}
<apex:column headerValue="Total">
<apex:inputText value="{!e1.total}" id="kpt" style="width:40px;" html-readonly="true" onchange="calculate_finalValue();"/>
<apex:facet name="footer">
Grand Total:<apex:inputtext id="grndt" value="{!grandTotalVal}" style="width:40px;" html-readonly="true"/>
</apex:facet>
</apex:column>
Swamy,
Can I request you to tell me what is the code of value="{!grandTotalVal}"??
I am stuck, I really;y need your help.