BUG 6757 Request for IDs to Add Link into Grids solved.
- html ids have been added to template - function deleteGridRow has an optional parameter to ask or not about deleting confirmation. - improve in event ondeleterow, now it returns last row deleted.
This commit is contained in:
@@ -448,7 +448,8 @@ var G_Grid = function(oForm, sGridName){
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
this.deleteGridRow = function(sRow) {
|
||||
this.deleteGridRow = function(sRow, bWithoutConfirm){
|
||||
if (typeof bWithoutConfirm == 'undefined') bWithoutConfirm = false;
|
||||
var i, iRow, iRowAux, oAux, ooAux;
|
||||
if (this.oGrid.rows.length == 3) {
|
||||
new leimnud.module.app.alert().make( {
|
||||
@@ -456,10 +457,20 @@ var G_Grid = function(oForm, sGridName){
|
||||
});
|
||||
return false;
|
||||
}
|
||||
if (bWithoutConfirm){
|
||||
this.deleteRowWC(this,sRow).extend(this);
|
||||
}else{
|
||||
new leimnud.module.app.confirm().make( {
|
||||
label : G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
|
||||
action : function() {
|
||||
//this.aElements = [];
|
||||
this.deleteRowWC(this,sRow);
|
||||
}.extend(this)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.deleteRowWC = function(oObj, aRow){
|
||||
sRow = new String(aRow);
|
||||
sRow = sRow.replace('[', '');
|
||||
sRow = sRow.replace(']', '');
|
||||
iRow = Number(sRow);
|
||||
@@ -469,13 +480,13 @@ var G_Grid = function(oForm, sGridName){
|
||||
* Dynaform - by Nyeke <erik@colosa.com
|
||||
*/
|
||||
|
||||
deleteRowOnDynaform(this, iRow);
|
||||
deleteRowOnDynaform(oObj, iRow);
|
||||
|
||||
iRowAux = iRow + 1;
|
||||
while (iRowAux <= (this.oGrid.rows.length - 2)) {
|
||||
for (i = 1; i < this.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
||||
var oCell1 = this.oGrid.rows[iRowAux - 1].cells[i];
|
||||
var oCell2 = this.oGrid.rows[iRowAux].cells[i];
|
||||
while (iRowAux <= (oObj.oGrid.rows.length - 2)) {
|
||||
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
||||
var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i];
|
||||
var oCell2 = oObj.oGrid.rows[iRowAux].cells[i];
|
||||
switch (oCell1.innerHTML.replace(/^\s+|\s+$/g, '').substr(0, 6).toLowerCase()){
|
||||
case '<input':
|
||||
aObjects1 = oCell1.getElementsByTagName('input');
|
||||
@@ -495,11 +506,11 @@ var G_Grid = function(oForm, sGridName){
|
||||
if (aObjects.length > 0) {
|
||||
|
||||
if (aObjects[0]) {
|
||||
aObjects[0].id = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
aObjects[0].name = aObjects[0].id.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]');
|
||||
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) + '\]');
|
||||
if (aObjects[0].onclick) {
|
||||
sAux = new String(aObjects[0].onclick);
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
aObjects = oCell1.getElementsByTagName('a');
|
||||
@@ -507,7 +518,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, '\[' + (this.oGrid.rows.length - 2) + '\]') + ';');
|
||||
eval('aObjects[0].onclick = ' + sAux.replace(/\[1\]/g, '\[' + (oObj.oGrid.rows.length - 2) + '\]') + ';');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -553,7 +564,7 @@ var G_Grid = function(oForm, sGridName){
|
||||
}
|
||||
iRowAux++;
|
||||
}
|
||||
this.oGrid.deleteRow(this.oGrid.rows.length - 2);
|
||||
this.oGrid.deleteRow(oObj.oGrid.rows.length - 2);
|
||||
if (this.sAJAXPage != '') {
|
||||
}
|
||||
/* this slice of code was comented because it could be the problem to do that sum function is working wrong
|
||||
@@ -562,53 +573,50 @@ var G_Grid = function(oForm, sGridName){
|
||||
}*/
|
||||
//this slice of code was added to fill the grid after to delete some row
|
||||
this.aElements = [];
|
||||
for (var k=1;k<= this.oGrid.rows.length-2;k++){
|
||||
for (var i = 0; i < this.aFields.length; i++) {
|
||||
for (var k=1;k<= oObj.oGrid.rows.length-2;k++){
|
||||
for (var i = 0; i < oObj.aFields.length; i++) {
|
||||
var j = k;
|
||||
switch (this.aFields[i].sType) {
|
||||
switch (oObj.aFields[i].sType) {
|
||||
case 'text':
|
||||
this.aElements.push(new G_Text(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName));
|
||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
||||
if(this.aFields[i].oProperties.strTo) {
|
||||
this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
|
||||
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':
|
||||
this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
|
||||
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':
|
||||
this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j+ '][' + this.aFields[i].sFieldName));
|
||||
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':
|
||||
this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['+ this.aFields[i].sFieldName));
|
||||
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 (this.aFunctions.length > 0) {
|
||||
for (i = 0; i < this.aFunctions.length; i++) {
|
||||
oAux = document.getElementById('form[' + this.sGridName + '][1][' + this.aFunctions[i].sFieldName + ']');
|
||||
if (oObj.aFunctions.length > 0) {
|
||||
for (i = 0; i < oObj.aFunctions.length; i++) {
|
||||
oAux = document.getElementById('form[' + oObj.sGridName + '][1][' + oObj.aFunctions[i].sFieldName + ']');
|
||||
if (oAux) {
|
||||
switch (this.aFunctions[i].sFunction) {
|
||||
switch (oObj.aFunctions[i].sFunction) {
|
||||
case 'sum':
|
||||
this.sum(false, oAux);
|
||||
oObj.sum(false, oAux);
|
||||
break;
|
||||
case 'avg':
|
||||
this.avg(false, oAux);
|
||||
oObj.avg(false, oAux);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Fires OnAddRow Event
|
||||
if (this.ondeleterow) {
|
||||
this.ondeleterow();
|
||||
if (oObj.ondeleterow) {
|
||||
oObj.ondeleterow(iRow);
|
||||
}
|
||||
|
||||
}.extend(this)
|
||||
});
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
{if ($form->addRow) }
|
||||
<table class='Record'>
|
||||
<tr><td></td>
|
||||
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" /> <a class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
|
||||
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" /> <a id="form[{$form->name}][addLink]" class="GridLink" href="#" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow();return false;">{$form->NewLabel}</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user