In postEdit function, how to retrieve the the value of another field in the row.
In postEdit function, how to retrieve the the value of another field in the row.
I am using a postEdit function to retrieve the value of a changed field but need to also retrieve the value of another field in the row that is not editable.
My code snipet is below - her is the line I am using to access a static field - var specMethod = tableSpec_a.cell(1).data();
Code sample:
//** Update specification values in QMS when values change in QMSPRD_WK
editorSpec_a.on( 'postEdit', function (e, json, data, id) {
var form_num = document.getElementById("form_num").value;
var form_rev = document.getElementById("form_rev").value;
var locid = document.getElementById("form_location_id").value;
var modifier = editorSpec_a.modifier();
var specMethod = tableSpec_a.cell(1).data();
var columnIndex = tableSpec_a.cell(modifier).index().column;
// var columnValue = tableSpec_a.cell(modifier).data(columnIndex).value;
var columnValue = tableSpec_a.cell(modifier).data();
var rowData = tableSpec_a.row(modifier).data();
console.log('In postEdit function (a)');
console.log('Formula Number: ' + form_num);
console.log('Formula Rev: ' + form_rev);
console.log('LocID: ' + locid);
console.log('Spec Method: ' + specMethod);
console.log('Column Index: ' + columnIndex);
console.log('Column Value: ' + columnValue);
//console.log('Row Data: ' + Object.keys( json.data[0] ));
});
Thanks for any help you can provide.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
You can use the fourth id for that -
id
. That's the id of the row being edited, so you should be able to do something likePlease see example here. Could you look at that, please, and see if it helps. If it's still not working for you, please can you update my example, or link to your page, so that we can see the problem.
Cheers,
Colin
Thanks, Colin.
table.row(id).data() returns the entire row but I would like to reference the value of a single cell.
Any suggestions?
Thanks.
Use the
cell().data()
API. Maybe something liketable.cell( id, 3 ).data()
. Where 3 is the column number. See thecell-selector
docs for details of selecting specific cells.Kevin
The table.cell( id, 3 ).data() code seems to work but it returns data from the first row regardless which cell I am actually editing. The example referenced above uses editing buttons - I am using in-line editing. Is that an issue?
Thanks,
The
postEdit
docs state theid
parameter is theid
of the row. Colin's example works because the row id is an integer which is the same as the index. Instead of trying to use the index you probably will want to use the jQuery notation for an element id, ie,"#" + id
. See therow-selector
docs string ID example.I think you will want
able.cell( "#" + id, 3 ).data()
.Kevin