solved issue with delete multiple records
authorMartin Taal <martin.taal@openbravo.com>
Mon, 07 Feb 2011 18:43:27 +0100
changeset 10409 2c3a509d926c
parent 10408 405bc3b81e4f
child 10410 67b1779380be
solved issue with delete multiple records
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Mon Feb 07 18:23:16 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js	Mon Feb 07 18:43:27 2011 +0100
@@ -1143,12 +1143,12 @@
     }
   },
   
-  deleteRow: function(autoSaveDone){
+  deleteSelectedRows: function(autoSaveDone){
     // first save what we have edited
     if (!autoSaveDone) {
       var actionObject = {
           target: this,
-          method: this.deleteRow,
+          method: this.deleteSelectedRows,
           parameters: [true]
         };
       this.standardWindow.doActionAfterAutoSave(actionObject, true);
@@ -1163,16 +1163,19 @@
     }
     
     var callback = function(ok){
-      var i, data, error, removeCallBack = function(resp, data, req){
+      var i, data, deleteData, error, recordInfos = [], removeCallBack = function(resp, data, req){
         if (resp.status === isc.RPCResponse.STATUS_SUCCESS) {
           if (view.isShowingForm) {
             view.switchFormGridVisibility();
-            if (resp.clientContext && resp.clientContext.refreshGrid) {
-              view.viewGrid.filterData();
-            }
           }
           view.messageBar.setMessage(isc.OBMessageBar.TYPE_SUCCESS, null, OB.I18N.getLabel('OBUIAPP_DeleteResult', [deleteCount]));
-          view.viewGrid.filterData(view.viewGrid.getCriteria());
+          if (deleteData) {
+            // deleteData is computed below
+            for (var i = 0 ; i < deleteData.ids.length; i++) {
+              recordInfos.push({id: deleteData.ids[i]});
+            }
+            view.viewGrid.data.handleUpdate('remove', recordInfos);
+          }
           view.viewGrid.updateRowCountDisplay();
         } else {
           // get the error message from the dataObject 
@@ -1193,7 +1196,7 @@
         view.viewGrid.deselectAllRecords();
         
         if (selection.length > 1) {
-          var deleteData = {};
+          deleteData = {};
           deleteData.entity = view.entity;
           deleteData.ids = [];
           for (i = 0; i < selection.length; i++) {
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Mon Feb 07 18:23:16 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-toolbar.js	Mon Feb 07 18:43:27 2011 +0100
@@ -81,7 +81,7 @@
   },
   DELETE_BUTTON_PROPERTIES: {
     action: function(){
-      this.view.deleteRow();
+      this.view.deleteSelectedRows();
     },
     disabled: true,
     buttonType: 'eliminate',