In editor event callback function, how to get the current editing colomns

In editor event callback function, how to get the current editing colomns

xyyl619xyyl619 Posts: 15Questions: 6Answers: 0
edited May 2015 in Editor

When I use editor event callback function, if i want to get the current column and row index that is current edited, how can i get that? thanks.Below is the code.

detailEditor.on('setData', function(e, json,data, action){
        //here how can i get the current column and row index that is current edited
        return ;
    });

This question has an accepted answers - jump to answer

Answers

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

    Use the modifier() method to get whatever element triggered the edit (probably the cell node in this case). You can then use cell().index() with the cell.

    Allan

  • xyyl619xyyl619 Posts: 15Questions: 6Answers: 0

    thanks for answer,
    but use modifier i can only get the row index, i still can't get column index,here is the explanation in api documnet

    On edit: -type integer - The DataTable row index for the row to be edited
    On remove: -type array - An array of DataTables row indexes for the rows to be removed.
    
  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin

    The modifier will give whatever you started the editing with - so if it was editor.inline( myTdCell ) modifier would give you back myTdCell.

    Can you give me a link to the page you are working on so I can see what is happening please?

    Allan

  • xyyl619xyyl619 Posts: 15Questions: 6Answers: 0

    js code is like this

    //fee_table is a table initialized with datatable
    $('#fee_table').on( 'click', 'tbody td:nth-child(3)', function (e) {
            feeEditor.inline( this, {submitOnBlur: true});
        } );    
        
        feeEditor.on('setData', function(e, json,data, action){
            data.changeFlag = 'changed';
            var modifier = feeEditor.modifier();
            //here the editor is the row number.
            if ( modifier ) {
                var index = feeEditor.cell( modifier ).index();
            
            }
            return ;
        });
    
    
  • allanallan Posts: 61,726Questions: 1Answers: 10,110 Site admin
    Answer ✓

    Hi,

    Thanks for your code - this I think looks like a bug in the current version of Editor. I'm currently rewriting that part for the next version, so I will ensure that this is addressed. However, what you could do in the mean time is just save the cell in a variable:

    var cell;
    //fee_table is a table initialized with datatable
    $('#fee_table').on('click', 'tbody td:nth-child(3)', function(e) {
        cell = this;
    
        feeEditor.inline(this, {
            submitOnBlur: true
        });
    });
    
    feeEditor.on('setData', function(e, json, data, action) {
        data.changeFlag = 'changed';
        var index = feeEditor.cell( cell ).index();
    
        ...
        return;
    });
    

    Allan

  • xyyl619xyyl619 Posts: 15Questions: 6Answers: 0

    hello, about this question ,within the new version, how i can get the column now editing?
    thanks

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

    Using the code you had above. You just need to access the column property of the index that you get from the cell.

    Allan

This discussion has been closed.