I am attaching onEditCell to send cell changes to update my database. The event fires both when double clicking to invoke edit, and after losing focus. I only want it to fire on losing focus IF the value has changed. Here’s my code, thanks in advance…
$(function() {
function doOnLoad(){
// init grid and set its parameters (this part as always)
myGrid = new dhtmlXGridObject('gridbox');
myGrid.setImagePath("codebase/imgs/");
myGrid.setHeader("KEY,ASSET TAG,SERIAL NO,MODEL NO,ASSET TYPE,ASSET SUB TYPE,ACQUISITION,COST TYPE,COST,QUANTITY,MANUFACTURER,SUPPLIER,CAPITALIZED,TAGGED,USEFUL LIFE,LOCATION,ROOM,STATUS,PURCHASE_DATE,INVENTORY DATE,SCAN DATE,FUND CODE,PO,CHECK NO,INVOICE,VOUCHER,COMMENTS");
myGrid.attachHeader(",#text_filter,#text_filter,#text_filter,#select_filter,#select_filter,#select_filter,#select_filter,#numeric_filter,#numeric_filter,#text_filter,#text_filter,#select_filter,#select_filter,#select_filter,#select_filter,#text_filter,#select_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
myGrid.setColTypes("ed,ed,ed,ed,ed,ed,ed,ed,price,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed,ed");
myGrid.setNumberFormat(",,,,,,,,'0,000.00',0,,,,,,,,,,,,,,,,,,,,,");
myGrid._in_header_stat_total=function(tag,index,data){
var calck=function(){
var sum=0;
var i = 0;
this.forEachRow(function(id){
i = parseFloat(this.cellById(id,index).getValue());
sum+=i*1;
sum = parseFloat(sum);
})
return this._aplNF(sum,2);
}
this._stat_in_header(tag,calck,index,data);
}
myGrid.attachFooter(",,,,,,,,Total Inv: ${#stat_total},Count: {#stat_count},,,,,,,,,,,,,,,,,,,,");
myGrid.setInitWidths("50,100,120,150,150,150,150,150,120,100,150,200,150,50,60,100,200,100,100,100,100,220,150,100,120,120,600,600,75,75");
myGrid.setColAlign("right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right,right");
myGrid.setDateFormat("%m-%d-%Y");
myGrid.setColSorting("int,int,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,str,date,date,date,str,str,str,str,str,str");
myGrid.enableMultiselect(true);
myGrid.enableBlockSelection(true);
myGrid.forceLabelSelection(true);
myGrid.copyBlockToClipboard(); // allow user to copy selected cell(s)
myGrid.attachEvent("onKeyPress",onKeyPressed);
function onKeyPressed(code,ctrl,shift){
if(code==67&&ctrl){
if (!myGrid._selectionArea) {
new Messi('Please select a block area in the grid.',{autoclose: 3000, title: 'Block Selection',titleClass:'error'});
}
else {
myGrid.setCSVDelimiter("t");
myGrid.copyBlockToClipboard( new Messi('Your selection has been saved to the Clipboard',{autoclose: 3000, title: 'Block Selection',titleClass:'success'}));
}
}
if(code==86&&ctrl){
myGrid.setCSVDelimiter("\t");
myGrid.pasteBlockFromClipboard()
}
return true;
};
myGrid.pasteBlockFromClipboard(); // allow user to paste into cells
myGrid.init();
myGrid.enableSmartRendering(true,50);
gridQString = "ajax/tempGridAssets.php";
myGrid.load( gridQString, 'json' );
myDataProcessor = new dataProcessor("ajax/updateTemp.php"); // lock feed url
myDataProcessor.setTransactionMode("POST",true); // set mode as send-all-by-post
myDataProcessor.setUpdateMode("off"); // disable auto-update
myDataProcessor.init(myGrid); // link dataprocessor to the grid
};
$(window).load(function(){
doOnLoad();
myGrid.attachEvent( "onEditCell", function (stage,rId,cInd,nValue){
new Messi(nValue,{autoclose: 3000, title: 'Cell Change',titleClass:'success'});
return true;
});
});
});