From: <cos...@us...> - 2011-06-21 18:34:32
|
Revision: 5373 http://jaffa.svn.sourceforge.net/jaffa/?rev=5373&view=rev Author: cosbor11 Date: 2011-06-21 18:34:26 +0000 (Tue, 21 Jun 2011) Log Message: ----------- added multikey delete support for grids in the getModifiedPanelStore() method Modified Paths: -------------- trunk/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js Modified: trunk/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js =================================================================== --- trunk/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js 2011-06-21 01:31:20 UTC (rev 5372) +++ trunk/JaffaRIA/source/html/js/extjs/jaffa/component/PanelController.js 2011-06-21 18:34:26 UTC (rev 5373) @@ -278,19 +278,24 @@ if (store.getDeletedRecords()) { var recs = store.getDeletedRecords(); for (var i=0; i<recs.length; i++) { - var recId = store.reader.getId(recs[i].json); + var recId = store.reader.getId(recs[i].json); if (recId && !recs[i].isNew) { - /* commented out because it causes duplicate saveGraphs to be added to saveModel - for (var j=0; j<origGraph.length; j++) { - if (recId == store.reader.getId(origGraph[j])) { //mark model for deletion so other components know it will be deleted - origGraph[j].deleteObject = true; + var isInNewGraph = false; + for (var k=0; k<newGraph.length; k++) { + if(Ext.isArray(recId) && Ext.isArray(keyField)){ //multi-key support, note: you may need to override reader.getId() to return an array + var isFound = null; + for(var x=0; x<keyField.length; x++){ + isFound = (recId[x] == newGraph[k][keyField[x]]); + if(isFound === false){ + break; + } + } + if(isFound){ + newGraph[k].deleteObject = true; isChanged = true; - } - } - */ - var isInNewGraph = false; - for (var k=0; k<newGraph.length; k++) { - if (recId == newGraph[k][keyField]) { //mark savemodel for deletion + isInNewGraph = true; + } + } else if(recId == newGraph[k][keyField]) { newGraph[k].deleteObject = true; isChanged = true; isInNewGraph = true; @@ -298,7 +303,13 @@ } if(!isInNewGraph && keyField){ var delObj = {deleteObject: true}; - delObj[keyField] = recId; + if(Ext.isArray(recId) && Ext.isArray(keyField)){ //multi-key support + for(var x=0; x<keyField.length; x++){ + delObj[keyField[x]] = recId[x]; + } + } else { + delObj[keyField] = recId; + } newGraph.push(delObj); isChanged = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |