Calculate total in editor window

Calculate total in editor window

rangaranga Posts: 22Questions: 8Answers: 2

Hi All
i need to have calculated column based on quantity and price . since im using row grouping plugin ,render method is not working with group total. so i need to know a way to do so in the editor window or at posting time within the editor instance.

i saw Field::inst but its for php i guess. so can some body en light me how to do it in mvc c#.

Thank You

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 47,740Questions: 1Answers: 6,824 Site admin
    Answer ✓

    Just to confirm what you are looking for me - you want a readonly field which contains a value calculated from two other fields? If so, use dependent() to update a readonly field's value (field().val()) when the two input values change.

    Allan

  • rangaranga Posts: 22Questions: 8Answers: 2

    Thanks Allan
    sorry for the late reply.
    Achieved through "dependent"

    editor.dependent('POPM_Item_ItemCost', function (val, data) {
    var quant = Number(editor.field('POPM_Item_ItemCost').val());
    var sell = Number(editor.field('POPM_Item_Quantity').val());
    var total = quant * sell;
    console.log('total is ' + total);
    editor.set('POPM_Item_TotalAmount', (total));

Sign In or Register to comment.