How to add calculated column in Editor

How to add calculated column in Editor

meskimeskimeskimeski Posts: 7Questions: 4Answers: 0

Hi! Hope for your help!
I need to add calculated column in my datatable in editor
i have code like this:

var table = $('#data').DataTable( {

    dom: "Bfrtipl",
    lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
    scrollY:        "600",
    scrollCollapse: true,
    paging:         false,
    ajax: 'server-response.php',
       columns: [
        { data: 'id' },
        { data: 'date' },
        { data: 'destination' },
        { data: 'client' },
        { data: 'load' },
        { data: 'product' },
        { data: 'prepay' },
        { data: 'cpay' },
        { data: 'wpay' },
       

i need to add one more column where will be result of 'cpay' - (minus) 'wpay'
how can i make this?

Answers

  • meskimeskimeskimeski Posts: 7Questions: 4Answers: 0

    Morning comes and issue comes:

    i make it using render
    the last line now like this:

    { data: null,
              render: function(data, type, row) { 
              return row.cpay - row.wpay; }
                     
            }
    

    But if use inline editor - i have error in console when click on calculated data

  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin

    Yes, you can't edit the calculated column - you would edit the columns that the calculation is based on.

    This example shows how you have have inline editing on specific columns only.

    Allan

This discussion has been closed.