Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think the stock answer above from datatables.net site was not helpful and didn't answer the question.</p> <p>I believe neko_ime wants to get the column header value corresponding to the column of the selected item (since this is probably the same as the column name in the table, or the user has a mapping between the table header and the database table).</p> <p><strong>here is how you get the sTitle (column name value) for a given cell</strong> </p> <p>(note I have my primary key in first column of every row, and have made sure that even if using movable columns with ColReorder that iFixedColumns is 1, to keep that key in the first column. my datatable is referenced by oTable. I am assuming that I have the cell DOM reference, which I call 'target' below):</p> <pre><code>var value = target.innerHTML; var ret_arr = oTable.fnGetPosition( target ); // returns array of 3 indexes [ row, col_visible, col_all] var row = ret_arr[0]; var col = ret_arr[1]; var data_row = oTable.fnGetData(row); var primary_key = data_row[0]; var oSettings = oTable.fnSettings(); // you can find all sorts of goodies in the Settings var col_id = oSettings.aoColumns[col].sTitle; //for this code, we just want the sTitle // you now have enough info to craft your SQL update query. I'm outputting to alert box instead alert('update where id="'+primary_key+'" set column "'+col_id+'" ('+row+', '+col+') to "'+value+'"'); </code></pre> <p>This is something I had to figure out myself, since i'm using JEditable to allow users to edit cells in the table.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload