Calculated (dependent) value record update in related column

Calculated (dependent) value record update in related column

hbanaharishbanaharis Posts: 32Questions: 14Answers: 3
edited April 2017 in Editor

Im able to change the CSS properties of a cell based on its contents using this method:

"columnDefs": [ {
                "targets": 7,
                "createdCell": function (td, cellData, rowData, row, col) {
                  if ( cellData < 1.6 ) {
                    $(td).css('color', 'red')
                  }
                }
              },

What type of method would I use to change the contents of another column (based on a conditional calculation similar to the one above) in the same row and have that column value be updated in the database?

I suspect that this functionality may be encompassed by the https://editor.datatables.net/reference/api/dependent() function.

If so, what would be an example that shows how to set the value of a related column, i.e. "if cellData <1.6 in column 7 then set column 8 to 'low' (and update database)".

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    It sounds like you want to change the value when the data is being read. I would suggest that is inefficient since it might end up being set multiple times. Instead, I would suggest you write the value to the database when you are writing the data into the database in the first place.

    If you are using the Editor libraries, you could use server-side events for that.

    Allan

This discussion has been closed.