Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82141

Inline Edit Data Not Retained After Subsequent Filter or Sort

$
0
0
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:
              var aPos = oTable.fnGetPosition(this);
              oTable.fnUpdate(sValue,aPos[0],aPos[1]);

Thanks,
--Tom

$(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);  
      }
    }
  } );
} );

Viewing all articles
Browse latest Browse all 82141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>