← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7276: Press Enter key to focus next cell for input data-value in tabular report.

 

------------------------------------------------------------
revno: 7276
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-06-12 13:02:21 +0700
message:
  Press Enter key to focus next cell for input data-value in tabular report.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-12 05:26:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-12 06:02:21 +0000
@@ -1111,8 +1111,20 @@
 			}
 			return 'textfield';
 		},
-		save: function( psiId, deId, value)
+		save: function(e)
 		{
+			var grid = TR.datatable.datatable;
+			grid.getView().getNode(e.rowIdx).classList.remove('hidden');
+			
+			var oldValue = e.originalValue;
+			var value = e.value;
+			if( value == oldValue)
+			{
+				return false;
+			}
+			
+			var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
+			var deId = e.column.name.split('_')[1];
 			var params = 'programStageInstanceId=' + psiId; 
 				params += '&dataElementId=' + deId;
 				params += '&value=' ;
@@ -1123,7 +1135,15 @@
 				url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.datavalue_save,
 				method: 'POST',
 				params: params,
-				success: function() {}
+				success: function() {
+					var rowIdx = e.rowIdx;
+					var colIdx = e.colIdx + 1;
+					if( e.colIdx == TR.datatable.datatable.columns.length - 1 ){
+						colIdx = 0;
+						rowIdx++;
+					}
+					TR.datatable.cellEditing.startEditByPosition({row: rowIdx, column: colIdx});
+				}
 			});
 		},
 		remove: function( psiId, rowIdx )
@@ -1396,18 +1416,7 @@
 						}
 					},
 					edit: function( editor, e ){
-						var grid = TR.datatable.datatable;
-						grid.getView().getNode(e.rowIdx).classList.remove('hidden');
-						
-						var oldValue = e.originalValue;
-						var newValue = e.value;
-						if( newValue == oldValue)
-						{
-							return false;
-						}
-						var psiId = TR.store.datatable.getAt(e.rowIdx).data['id'];
-						var deId = e.column.name.split('_')[1];
-						TR.value.save( psiId, deId, newValue);
+						TR.value.save(e);
 					},
 					canceledit: function( grid, eOpts ){
 						if( e.rowIdx == 0 ){