After editing a cell, what is the best approach to update another cell's value?

After editing a cell, what is the best approach to update another cell's value?

cwraabcwraab Posts: 6Questions: 0Answers: 0
edited July 2011 in General
First, thank you for DataTables. I appreciate your hard work. I've been searching the forums and playing with different options. I basically have a cell that has a jEditable select custom editor. I would like to update another cell based on a user's selection in the select box. I'm using a combination of jEditable, KeyTable, and AutoFill. I'm not very experienced with jQuery unfortunately.

I've tried using sUpdateURL, was able to obtain current cell's value, but was unable to obtain the current cell's position to pass to fnUpdate.
I've tried using fnOnEditing, was able to obtain current cell's value, but was unable to obtain the current cell's position to pass to fnUpdate.
I've tried using a onBlur event listener, was able to obtain current cell's postion, but was unable to obtain the current cell's value to pass to fnUpdate.

Can anybody point me in the right direction here? I've been trying to solve this for hours now. Any help would greatly be appreciated.

Thanks

Replies

  • cwraabcwraab Posts: 6Questions: 0Answers: 0
    anybody?
  • tedkalawtedkalaw Posts: 12Questions: 0Answers: 0
    edited July 2011
    You can get the position of the cell that was edited with fnGetPosition(object). This'll return an array with the row at index 0 and the column at index 1.

    It's similar to the example for jEditable here:
    http://datatables.net/release-datatables/examples/server_side/editable.html

    EDIT: Ok, I have no idea where I actually got it from, but you should be able to use fnGetPosition. Here's code of mine that calls a function and then updates another column (column 2) based on the user's input:

    [code]
    $('td', oTable.fnGetNodes()).editable('/submit_grade', {
    "callback" : function(value, settings) {
    var aPos = oTable.fnGetPosition(this);
    oTable.fnUpdate(value, aPos[0], aPos[1]);
    var grade = calculateGrade($(this).parent(), scale);
    //updates column 2 in the same row
    oTable.fnUpdate(grade, aPos[0], 2);
    },
    "submitdata" : function(value, settings){
    return {
    "row_id": this.parentNode.getAttribute('id'),
    "column": oTable.fnGetPosition(this)[2]
    };
    }
    });
    [/code]

    Hope it helps.
  • cwraabcwraab Posts: 6Questions: 0Answers: 0
    Thank you very much
This discussion has been closed.