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.

mikducmikduc Posts: 31Questions: 8Answers: 0
edited June 2022 in Editor

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

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    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 like :smile:

    table.row(id).data()
    

    Please 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

  • mikducmikduc Posts: 31Questions: 8Answers: 0

    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.

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    Use the cell().data() API. Maybe something like table.cell( id, 3 ).data(). Where 3 is the column number. See the cell-selector docs for details of selecting specific cells.

    Kevin

  • mikducmikduc Posts: 31Questions: 8Answers: 0

    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,

  • kthorngrenkthorngren Posts: 21,327Questions: 26Answers: 4,949

    The postEdit docs state the id parameter is the id 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 the row-selector docs string ID example.

    I think you will want able.cell( "#" + id, 3 ).data().

    Kevin

Sign In or Register to comment.