From 269cc4d3931d7995ad69dd2c505ca803353dacb1 Mon Sep 17 00:00:00 2001 From: Enrique Ponce De Leon Date: Mon, 25 Apr 2011 16:48:37 -0400 Subject: [PATCH] BUG 6782 Grid Currency Mask error when removes a row Solved. --- gulliver/js/grid/core/grid.js | 60 ++++++++--------------------------- 1 file changed, 13 insertions(+), 47 deletions(-) diff --git a/gulliver/js/grid/core/grid.js b/gulliver/js/grid/core/grid.js index 565146972..04fe3d673 100644 --- a/gulliver/js/grid/core/grid.js +++ b/gulliver/js/grid/core/grid.js @@ -475,15 +475,11 @@ var G_Grid = function(oForm, sGridName){ sRow = sRow.replace(']', ''); iRow = Number(sRow); - /* - * delete the respective session row grid variables from - * Dynaform - by Nyeke 0) { if (aObjects[0]) { - aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]'); - aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]'); + aObjects[0].id = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]'); + aObjects[0].name = aObjects[0].id.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]'); if (aObjects[0].onclick) { sAux = new String(aObjects[0].onclick); - eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';'); + eval('aObjects[0].onclick = ' + sAux.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]') + ';'); } } aObjects = oCell1.getElementsByTagName('a'); @@ -518,7 +511,7 @@ var G_Grid = function(oForm, sGridName){ if (aObjects[0]) { if (aObjects[0].onclick) { sAux = new String(aObjects[0].onclick); - eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';'); + eval('aObjects[0].onclick = ' + sAux.replace('/\['+ (iRowAux -1 ) + '\]/g', '\[' + iRowAux + '\]') + ';'); } } } @@ -564,40 +557,12 @@ var G_Grid = function(oForm, sGridName){ } iRowAux++; } - this.oGrid.deleteRow(oObj.oGrid.rows.length - 2); - if (this.sAJAXPage != '') { + this.oGrid.deleteRow(lastItem); + + for (i=0; i < this.aFields.length; i++){ + this.aElements.pop(); } - /* this slice of code was comented because it could be the problem to do that sum function is working wrong - if (this.aFields.length > 0) { - this.unsetFields(); - }*/ - //this slice of code was added to fill the grid after to delete some row - this.aElements = []; - for (var k=1;k<= oObj.oGrid.rows.length-2;k++){ - for (var i = 0; i < oObj.aFields.length; i++) { - var j = k; - switch (oObj.aFields[i].sType) { - case 'text': - oObj.aElements.push(new G_Text(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName)); - oObj.aElements[oObj.aElements.length - 1].validate = oObj.aFields[i].oProperties.validate; - if(oObj.aFields[i].oProperties.strTo) { - oObj.aElements[oObj.aElements.length - 1].strTo = oObj.aFields[i].oProperties.strTo; - } - break; - case 'currency': - oObj.aElements.push(new G_Currency(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + ']['+ oObj.aFields[i].sFieldName)); - break; - case 'percentage': - oObj.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j+ '][' + oObj.aFields[i].sFieldName)); - break; - case 'dropdown': - oObj.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + oObj.sGridName + '][' + j + '][' + oObj.aFields[i].sFieldName + ']'), oObj.sGridName + '][' + j + ']['+ oObj.aFields[i].sFieldName)); - break; - } - j++; - } - } - + if (oObj.aFunctions.length > 0) { for (i = 0; i < oObj.aFunctions.length; i++) { oAux = document.getElementById('form[' + oObj.sGridName + '][1][' + oObj.aFunctions[i].sFieldName + ']'); @@ -613,7 +578,8 @@ var G_Grid = function(oForm, sGridName){ } } } - //Fires OnAddRow Event + + //Fires OnAddRow Event if (oObj.ondeleterow) { oObj.ondeleterow(iRow); }