Add and subtract In Editor
Add and subtract In Editor

I would like to take column data and add / subtract depending on value.
IE: col1 + col2 - col3
And col2 is a key index of another table.
columnDefs: [
{
"targets": 5, #col1
"data": null,
"render": function(data, type, full, meta, row) {
return '$' + data;
}
},
{
"targets": 6, #col2
"data": null,
"render": function(data, type, full, meta, row) {
return '$' + data;
}
},
{
"targets": 7, #col3
"data": null,
"render": function(data, type, full, meta, row) {
return '$' + data;
}
},
],
Editor::inst( $db, '_devices' )
->fields(
Field::inst( '_devices.ID' ),
Field::inst( '_devices.d_modified' )
->validator( Validate::dateFormat( 'Y-m-d H:i:s' ) )
->getFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) )
->setFormatter( Format::datetime( 'Y-m-d H:i:s', 'Y-m-d H:i:s' ) ),
Field::inst( '_devices.d_dpmax' ),
Field::inst( '_devices.d_model' ),
Field::inst( '_devices.d_make' ),
Field::inst( '_devices.d_upc' ),
Field::inst( '_devices.d_sku' ),
Field::inst( '_devices.d_category' ), #this is column 2
Field::inst( '_cost.c_sku' ),
Field::inst( '_cost.c_cost_ingram' ),
Field::inst( '_cost.c_cost_vzw' ),
Field::inst( '_cat.ID' ),
Field::inst( '_cat.commission' ),
)
->leftJoin( '_cost', '_cost.c_sku', '=', '_devices.d_sku' )
->leftJoin( '_cat', '_cat.ID', '=', '_devices.d_category' )
Column 2 will have a value of 34 which equals $130 or value 22 which equals $90
Thank you
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I assume that column would be read-only, as it's based on other data. If so, you would do this in
columns.render
- the third parameter contains the data for the other columns that you can use.Colin
@colin
Thank you for your feedback. I did manage to get this working last night.
Here is my code sample.
Result (Sorry I have to blur some things out. The final result is last column.