Calculate total in editor window

Calculate total in editor window

rangaranga Posts: 31Questions: 12Answers: 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: 63,455Questions: 1Answers: 10,465 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: 31Questions: 12Answers: 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));

This discussion has been closed.