Inline Edit Data Not Retained After Subsequent Filter or Sort
Inline Edit Data Not Retained After Subsequent Filter or Sort

I have two columns in my table which contain a drop-down for inline editing. When double-clicking on the cell, the drop-down appears, after making a selection and leaving the cell the value in the cell is updated on the screen. The problem is that when the table is subsequently sorted or filtered, the original value is restored into the previously edited cell.
Here is the code I am using to attempt to update the underlying data, but when leaving the cell, the following error, "Uncaught TypeError: Cannot read property '0' of null", is generated.
Best I can troubleshoot, the following two lines are causing the error:
[code]
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue,aPos[0],aPos[1]);
[/code]
Thanks,
--Tom
[code]
$(document).ready(function() {
var oTable = $('#mtTable').dataTable( {
.
. (omitted for brevity)
.
"fnDrawCallback": function ( oSettings ) {
var that = this;
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
this.\$('td:first-child', {"filter":"applied"}).each( function (i) {
that.fnUpdate( i+1, this.parentNode, 0, false, false );
} );
setTimeout( function() {
\$(".editCat").editable("process_category_change.cgi?callletters=XXXX", {
"callback":function(sValue,y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue,aPos[0],aPos[1]);
},
tooltip: "Double-click to edit...",
data : "{'-1':'(clr)','0':' ','1':'A1'}",
type : "select",
event : "dblclick",
onblur : "submit",
style : "inherit"
});
},0);
}
}
} );
} );
[/code]
Here is the code I am using to attempt to update the underlying data, but when leaving the cell, the following error, "Uncaught TypeError: Cannot read property '0' of null", is generated.
Best I can troubleshoot, the following two lines are causing the error:
[code]
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue,aPos[0],aPos[1]);
[/code]
Thanks,
--Tom
[code]
$(document).ready(function() {
var oTable = $('#mtTable').dataTable( {
.
. (omitted for brevity)
.
"fnDrawCallback": function ( oSettings ) {
var that = this;
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
this.\$('td:first-child', {"filter":"applied"}).each( function (i) {
that.fnUpdate( i+1, this.parentNode, 0, false, false );
} );
setTimeout( function() {
\$(".editCat").editable("process_category_change.cgi?callletters=XXXX", {
"callback":function(sValue,y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue,aPos[0],aPos[1]);
},
tooltip: "Double-click to edit...",
data : "{'-1':'(clr)','0':' ','1':'A1'}",
type : "select",
event : "dblclick",
onblur : "submit",
style : "inherit"
});
},0);
}
}
} );
} );
[/code]
This discussion has been closed.
Replies
http://datatables.net/forums/discussion/14646/fngetposition-returns-cannot-read-property-ntr-of-undefined-when-called-on-table-w-fixed-cols
After some further research, it appears that the use of the Fixed Columns feature is a contributor to this problem.
[code]
new FixedColumns(oTable,{"iLeftColumns":6,"iLeftWidth":500});
[/code]
When referencing columns on the right side of the split, the following lines work:
[code]
var oTable = $('#mtTable').dataTable();
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue,aPos[0],aPos[1]);
[/code]
But, the first column on the right side has an index of zero.
How would I access the columns on the left side of the split, perhaps a different table name in the "var oTable = " statement?