How to multiply two fields together and display result in 4th column in datatable


I have a data table two of the fields represent dropdowns with numbers 1,2,3,4,5 the 4th column is where I want to display the result of multiplying column 2 X column 3 = column 4. How do I do this?

Hello @MartinM,

This can be done using the code:

    //Make the fourth column noneditable
    fd.control('DataTable1').columns[3].editable = function(){return false};

    fd.control('DataTable1').$on('change', function(value) {
        //if there are records in the table
        var isTableModified = false;
            //go through each one by one
            for (var i = 0; i < value.length; i++){
                //replace Column1 and Column2 with the internal names of the columns
                if(value[i].Column1 && value[i].Column2){
                    //set LineTotal to their product
                    var lineTotal = value[i].Column1 * value[i].Column2;

                    //replace Column3 with the internal name of the columns
                    if (value[i].Column3 != lineTotal ) {
                        value[i].Column3 = lineTotal;
                        isTableModified = true;

        //here we refresh the table
        if (isTableModified) {

Please find more examples on how to work with DataTable in our documentation here.

Thank you for the quick replay. Still having issues hopefully this image will explain it.

Also, how do we mark a column as not editable?


As column type is a drop down, you need to convert the string values to numbers like this:

var lineTotal = Number(value[i].Column1) * Number(value[i].Column2);

To disable the column, use this code:

how to do it on the current row only instead of full table data.

Hello @Derek_wong,

You can find instructions and a code examples on how to calculate totals for the row and the table in our documentation here: