Improved selection behavior in grid
authorMartin Taal <martin.taal@openbravo.com>
Sat, 15 Jan 2011 16:58:51 +0100
changeset 9839 43b9ea3ec34b
parent 9838 8db66b8fe082
child 9840 dedb0498fda1
Improved selection behavior in grid
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
--- a/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Sat Jan 15 16:58:30 2011 +0100
+++ b/modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js	Sat Jan 15 16:58:51 2011 +0100
@@ -577,46 +577,22 @@
     }
   },
   
-  // selectionChanged is called when the user makes changes
-  selectionChanged: function(record, state){
+  selectionUpdated: function(record, recordList){
   
     this.stopHover();
-    
-    // enable/disable the delete if there are records selected
-    this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, (!this.getSelection() || this.getSelection().length === 0));
+    this.updateSelectedCountDisplay();
     
     // nothing changed, go away then, happens when saving
-    if (state && this.view.lastRecordSelected && record && this.view.lastRecordSelected.id === record.id) {
+    if (this.singleRecordSelection && this.view.lastRecordSelected && this.getSelection().length === 1 && this.getSelection()[0].id === this.view.lastRecordSelected.id) {
       // instance may have been updated, update the instance in the view
-      this.view.lastRecordSelected = record;
+      this.view.lastRecordSelected = this.getSelection()[0];
       return;
     }
-    
-    // stop editing if the selection is changing  
-    var rowNum = this.getRecordIndex(record);
-    
-    if (this.getEditRow()) {
-      if (this.getEditRow() !== rowNum) {
-        this.endEditing();
-      } else {
-        // don't do any updates
-        this.updateSelectedCountDisplay();
-        return;
-      }
-    }
-    
-    isc.Log.logDebug('Selection changed ' + state, 'OB');
-    this.updateSelectedCountDisplay();
-    this.view.recordSelected();
-  },
-  
-  // selectionUpdated is called when the grid selection is changed
-  // programmatically
-  selectionUpdated: function(record, recordList){
   
     isc.Log.logDebug('Selection updated ' + record, 'OB');
-    this.updateSelectedCountDisplay();
+
     this.view.recordSelected();
+
     // enable/disable the delete if there are records selected
     this.view.toolBar.setLeftMemberDisabled(isc.OBToolbar.TYPE_DELETE, (!this.getSelection() || this.getSelection().length === 0));
   },