BUG 9619 "Grillas: Problema en las dependencias al eliminar..." SOLVED
- When you delete a row of a grid in any order (not in sequential order) and then add a new row, dependent fields do not work. - Problem resuelo, dependent fields work correctly when you delete any row. * Available from version 2.0.44
This commit is contained in:
@@ -39,97 +39,93 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
};
|
};
|
||||||
|
|
||||||
//Begin SetFields ---------------------------------------------------------------------
|
//Begin SetFields ---------------------------------------------------------------------
|
||||||
this.setFields = function(aFields, iRow) {
|
this.setFields = function (aFields, iRow)
|
||||||
|
{
|
||||||
|
var tableGrid = document.getElementById(this.sGridName);
|
||||||
|
var element;
|
||||||
|
var elementName = "";
|
||||||
|
var i = 0;
|
||||||
|
var j = 0;
|
||||||
|
|
||||||
this.aFields = aFields;
|
this.aFields = aFields;
|
||||||
var i, j, k, aAux, oAux, sDependentFields;
|
|
||||||
for (i = 0; i < this.aFields.length; i++) {
|
for (i = iRow || 1; i <= tableGrid.rows.length - 2; i++) {
|
||||||
j = iRow || 1;
|
for (j = 0; j <= this.aFields.length - 1; j++) {
|
||||||
switch (this.aFields[i].sType) {
|
elementName = this.sGridName + "][" + i + "][" + this.aFields[j].sFieldName;
|
||||||
case 'text':
|
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')){
|
if ((element = document.getElementById("form[" + elementName + "]"))) {
|
||||||
this.aElements.push(
|
switch (this.aFields[j].sType) {
|
||||||
new G_Text(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
case "text":
|
||||||
+ this.aFields[i].sFieldName));
|
this.aElements.push(new G_Text(oForm, element, elementName));
|
||||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
this.aElements[this.aElements.length - 1].validate = this.aFields[j].oProperties.validate;
|
||||||
if(this.aFields[i].oProperties.strTo) {
|
|
||||||
this.aElements[this.aElements.length - 1].strTo = this.aFields[i].oProperties.strTo;
|
if (this.aFields[j].oProperties.strTo) {
|
||||||
|
this.aElements[this.aElements.length - 1].strTo = this.aFields[j].oProperties.strTo;
|
||||||
}
|
}
|
||||||
if (aFields[i].oProperties) {
|
|
||||||
this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.mask;
|
if (this.aFields[j].oProperties) {
|
||||||
}
|
this.aElements[this.aElements.length - 1].mask = this.aFields[j].oProperties.mask;
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "currency":
|
||||||
|
this.aElements.push(new G_Currency(oForm, element, elementName));
|
||||||
|
|
||||||
case 'currency':
|
if (this.aFields[j].oProperties) {
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
if (this.aFields[j].oProperties.comma_separator) {
|
||||||
this.aElements.push(new G_Currency(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[j].oProperties.comma_separator;
|
||||||
+ this.aFields[i].sFieldName));
|
|
||||||
|
|
||||||
if (this.aFields[i].oProperties) {
|
|
||||||
if (this.aFields[i].oProperties.comma_separator) {
|
|
||||||
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
this.aElements[this.aElements.length - 1].validate = this.aFields[j].oProperties.validate;
|
||||||
this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask;
|
this.aElements[this.aElements.length - 1].mask = this.aFields[j].oProperties.mask;
|
||||||
}
|
|
||||||
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "percentage":
|
||||||
|
this.aElements.push(new G_Percentage(oForm, element, elementName));
|
||||||
|
|
||||||
case 'percentage':
|
if (this.aFields[j].oProperties) {
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
if (this.aFields[j].oProperties.comma_separator) {
|
||||||
this.aElements.push(new G_Percentage(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j
|
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[j].oProperties.comma_separator;
|
||||||
+ '][' + this.aFields[i].sFieldName));
|
|
||||||
|
|
||||||
if (this.aFields[i].oProperties) {
|
|
||||||
if (this.aFields[i].oProperties.comma_separator) {
|
|
||||||
this.aElements[this.aElements.length - 1].comma_separator = this.aFields[i].oProperties.comma_separator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.aElements[this.aElements.length - 1].validate = this.aFields[i].oProperties.validate;
|
this.aElements[this.aElements.length - 1].validate = this.aFields[j].oProperties.validate;
|
||||||
this.aElements[this.aElements.length - 1].mask = this.aFields[i].oProperties.mask;
|
this.aElements[this.aElements.length - 1].mask = this.aFields[j].oProperties.mask;
|
||||||
}
|
|
||||||
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "dropdown":
|
||||||
|
this.aElements.push(new G_DropDown(oForm, element, elementName));
|
||||||
|
|
||||||
case 'dropdown':
|
if (this.aFields[j].oProperties) {
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
this.aElements[this.aElements.length - 1].mask = this.aFields[j].oProperties.sMask;
|
||||||
this.aElements.push(new G_DropDown(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
|
||||||
+ this.aFields[i].sFieldName));
|
|
||||||
if (aFields[i].oProperties) {
|
|
||||||
this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.sMask;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
this.aElements.push(new G_Field(oForm, element, elementName));
|
||||||
this.aElements.push(new G_Field(oForm, document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']'), this.sGridName + '][' + j + ']['
|
|
||||||
+ this.aFields[i].sFieldName));
|
if (this.aFields[j].oProperties) {
|
||||||
if (aFields[i].oProperties) {
|
this.aElements[this.aElements.length - 1].mask = this.aFields[j].oProperties.sMask;
|
||||||
this.aElements[this.aElements.length - 1].mask = aFields[i].oProperties.sMask;
|
|
||||||
}
|
|
||||||
j++;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set dependent fields
|
|
||||||
sw1 = false;
|
|
||||||
if (this.allDependentFields == '') sw1 = true; //Check if dependent fields are setted.
|
|
||||||
for (i = 0; i < this.aFields.length; i++) {
|
|
||||||
j = iRow || 1;
|
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + this.aFields[i].sFieldName + ']')) {
|
|
||||||
if (aFields[i].oProperties.dependentFields != '') {
|
|
||||||
this.setDependents(j, this.getElementByName(j, this.aFields[i].sFieldName), aFields[i].oProperties.dependentFields, sw1);
|
|
||||||
}
|
}
|
||||||
j++;
|
}
|
||||||
|
|
||||||
|
//Set dependent fields
|
||||||
|
var sw = false;
|
||||||
|
|
||||||
|
if (this.allDependentFields == "") {
|
||||||
|
sw = true; //Check if dependent fields are setted.
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j <= this.aFields.length - 1; j++) {
|
||||||
|
i = iRow || 1;
|
||||||
|
|
||||||
|
while ((element = document.getElementById("form[" + this.sGridName + "][" + i + "][" + this.aFields[j].sFieldName + "]"))) {
|
||||||
|
if (this.aFields[j].oProperties.dependentFields != "") {
|
||||||
|
this.setDependents(i, this.getElementByName(i, this.aFields[j].sFieldName), aFields[j].oProperties.dependentFields, sw);
|
||||||
|
}
|
||||||
|
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -201,88 +197,148 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
this.cloneElement = function (element)
|
||||||
|
{
|
||||||
|
//input, textarea, select
|
||||||
|
|
||||||
this.cloneInput = function(oNewObject){
|
var strHtml = element.parentNode.innerHTML;
|
||||||
var txt = oNewObject.parentNode.innerHTML;
|
var tag = new String(element.nodeName);
|
||||||
var xClass = 'module_app_input___gray';
|
var arrayMatch = [];
|
||||||
|
var arrayAux1 = [];
|
||||||
|
var arrayAux2 = [];
|
||||||
|
var strHtmlAux = "";
|
||||||
|
var strAux = "";
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
txt = txt.replace('input', '');
|
strHtml = stringReplace("\\x0A", "", strHtml); //\n 10
|
||||||
txt = txt.replace('INPUT', '');
|
strHtml = stringReplace("\\x0D", "", strHtml); //\r 13
|
||||||
txt = txt.replace('<', '');
|
strHtml = stringReplace("\\x09", "", strHtml); //\t 9
|
||||||
txt = txt.replace('/>', '');
|
|
||||||
txt = txt.replace('>', '');
|
|
||||||
|
|
||||||
var strAux = stringReplace(' ', '', txt);
|
if ((arrayMatch = eval("/^.*(<" + tag + ".*id=\"" + element.id + "\".*>).*$/i").exec(strHtml))) {
|
||||||
strAux = strAux.toLowerCase();
|
strHtml = arrayMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
var sw_display = (strAux.indexOf('display:none') > 0)? true : false;
|
strHtml = stringReplace("<" + tag, "", strHtml);
|
||||||
|
strHtml = stringReplace("<" + tag.toLowerCase(), "", strHtml);
|
||||||
|
strHtml = stringReplace("\\/>.*", "", strHtml);
|
||||||
|
strHtml = stringReplace(">.*", "", strHtml);
|
||||||
|
|
||||||
var arrayElemTxt = txt.split('="');
|
///////
|
||||||
var pos = 0;
|
strHtmlAux = strHtml;
|
||||||
var strAux2 = '';
|
strAux = "";
|
||||||
var strAux3 = '';
|
|
||||||
|
|
||||||
for (var i = 0; i <= arrayElemTxt.length - 1; i++) {
|
while ((arrayMatch = /^(.*)(".*")(.*)$/g.exec(strHtmlAux))) {
|
||||||
strAux = arrayElemTxt[i];
|
strHtmlAux = arrayMatch[1];
|
||||||
pos = strAux.indexOf('"');
|
strAux = stringReplace(" ", "__SPACE__", arrayMatch[2]) + arrayMatch[3] + strAux;
|
||||||
|
}
|
||||||
|
|
||||||
if (pos > 0) {
|
strAux = strHtmlAux + strAux;
|
||||||
strAux2 = strAux.substr(0, pos);
|
|
||||||
strAux3 = stringReplace(' ', '__%SPACE__', strAux2)
|
|
||||||
|
|
||||||
arrayElemTxt[i] = strAux.replace(strAux2, strAux3);
|
strHtml = strAux;
|
||||||
|
|
||||||
|
///////
|
||||||
|
if (/^.*read[oO]nly.*$/.test(strHtml)) {
|
||||||
|
if (!(/^.*read[oO]nly\=.*$/.test(strHtml))) {
|
||||||
|
strHtml = stringReplace("read[oO]nly", "readonly=\"\"", strHtml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
txt = arrayElemTxt.join('="');
|
if (/^.*disabled.*$/.test(strHtml)) {
|
||||||
|
if (!(/^.*disabled\=.*$/.test(strHtml))) {
|
||||||
|
strHtml = stringReplace("disabled", "disabled=\"\"", strHtml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
arrayElemTxt = txt.split(' ');
|
if (/^.*checked.*$/i.test(strHtml)) {
|
||||||
|
strHtml = stringReplace("CHECKED", "checked", strHtml);
|
||||||
|
|
||||||
|
if (!(/^.*checked\=.*$/.test(strHtml))) {
|
||||||
|
strHtml = stringReplace("checked", "checked=\"\"", strHtml);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////
|
||||||
var arrayAttribute = [];
|
var arrayAttribute = [];
|
||||||
var arrayAttributeValue = [];
|
var a = "";
|
||||||
var strStyle = '';
|
var v = "";
|
||||||
|
arrayAux1 = strHtml.split(" ");
|
||||||
|
|
||||||
for (var i = 0; i <= arrayElemTxt.length - 1; i++) {
|
for (i = 0; i <= arrayAux1.length - 1; i++) {
|
||||||
if (arrayElemTxt[i].indexOf('=') > 0) {
|
arrayAux2 = arrayAux1[i].split("=");
|
||||||
aVals = arrayElemTxt[i].split('=');
|
|
||||||
aVals[0] = aVals[0].toLowerCase();
|
|
||||||
aVals[1] = stringReplace('"', '', aVals[1])
|
|
||||||
aVals[1] = stringReplace('__%SPACE__', ' ', aVals[1])
|
|
||||||
|
|
||||||
if (aVals[0] != 'id' && aVals[0] != 'name' && aVals[0] != 'class' && aVals[0] != 'style') {
|
if (typeof arrayAux2[1] != "undefined") {
|
||||||
arrayAttribute.push(aVals[0]);
|
a = arrayAux2[0].trim();
|
||||||
arrayAttributeValue.push(aVals[1]);
|
v = stringReplace("\\\"", "", arrayAux2[1]);
|
||||||
} else {
|
|
||||||
if (aVals[0] == 'style') {
|
v = stringReplace("__SPACE__", " ", v);
|
||||||
strStyle = aVals[1];
|
|
||||||
}
|
arrayAttribute.push([a, v]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
strStyle = ((sw_display)? "display: none;" : "") + strStyle;
|
///////
|
||||||
|
var newElement = document.createElement(tag.toLowerCase());
|
||||||
|
|
||||||
var newField = document.createElement("input");
|
for (i = 0; i <= arrayAttribute.length - 1; i++) {
|
||||||
|
a = arrayAttribute[i][0];
|
||||||
|
v = arrayAttribute[i][1];
|
||||||
|
|
||||||
newField.setAttribute("id", oNewObject.id);
|
switch (a.toLowerCase()) {
|
||||||
newField.setAttribute("name", oNewObject.id);
|
case "id":
|
||||||
newField.className = xClass;
|
case "name":
|
||||||
newField.style.cssText = strStyle;
|
newElement.setAttribute("id", element.id);
|
||||||
|
newElement.setAttribute("name", element.id);
|
||||||
if (oNewObject.disabled) {
|
break;
|
||||||
newField.disabled = true;
|
case "class":
|
||||||
|
newElement.className = v;
|
||||||
|
break;
|
||||||
|
case "style":
|
||||||
|
newElement.style.cssText = ((/^.*display\s*:\s*none.*$/i.test(strHtml))? "display: none;" : "") + v;
|
||||||
|
break;
|
||||||
|
case "disabled":
|
||||||
|
if (element.disabled) {
|
||||||
|
newElement.disabled = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "readonly":
|
||||||
|
if (element.readOnly) {
|
||||||
|
newElement.readOnly = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "checked":
|
||||||
|
if (element.checked) {
|
||||||
|
newElement.checked = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newElement.setAttribute(a, v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oNewObject.readOnly) {
|
switch (tag.toLowerCase()) {
|
||||||
newField.readOnly = true;
|
case "input":
|
||||||
|
case "textarea":
|
||||||
|
newElement.value = element.value;
|
||||||
|
break;
|
||||||
|
case "select":
|
||||||
|
if (element.options.length > 0) {
|
||||||
|
var pos = 0;
|
||||||
|
|
||||||
|
for (i = 0; i <= element.options.length - 1; i++) {
|
||||||
|
if (element.options[i].selected) {
|
||||||
|
pos = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i <= arrayAttribute.length - 1; i++) {
|
newElement.options[i] = new Option(element.options[i].text, element.options[i].value, element.options[i].defaultSelected);
|
||||||
newField.setAttribute(arrayAttribute[i], arrayAttributeValue[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return newField;
|
newElement.options[pos].selected = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return newElement;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addGridRow = function() {
|
this.addGridRow = function() {
|
||||||
@@ -323,14 +379,18 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
aObjects[0].id = newID;
|
aObjects[0].id = newID;
|
||||||
aObjects[0].name = newID;
|
aObjects[0].name = newID;
|
||||||
attributes = elementAttributesNS(aObjects[0], 'pm');
|
attributes = elementAttributesNS(aObjects[0], 'pm');
|
||||||
if (attributes.defaultvalue != '' && typeof attributes.defaultvalue != 'undefined'){
|
|
||||||
|
if (typeof attributes.defaultvalue != "undefined" && attributes.defaultvalue != "") {
|
||||||
defaultValue = attributes.defaultvalue;
|
defaultValue = attributes.defaultvalue;
|
||||||
} else {
|
} else {
|
||||||
defaultValue = '';
|
defaultValue = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
for(n=0; n < aObjects.length; n++){
|
for(n=0; n < aObjects.length; n++){
|
||||||
switch(aObjects[n].type){
|
switch(aObjects[n].type){
|
||||||
case 'text': //TEXTBOX, CURRENCY, PERCENTAGE, DATEPICKER
|
case 'text': //TEXTBOX, CURRENCY, PERCENTAGE, DATEPICKER
|
||||||
|
aObjects[n].className = "module_app_input___gray";
|
||||||
|
|
||||||
tags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
tags = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('a');
|
||||||
if (tags.length == 2){ //DATEPICKER
|
if (tags.length == 2){ //DATEPICKER
|
||||||
//Copy Images
|
//Copy Images
|
||||||
@@ -363,36 +423,34 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
a2.id = datePickerTriggerId;
|
a2.id = datePickerTriggerId;
|
||||||
a2.innerHTML = img2;
|
a2.innerHTML = img2;
|
||||||
oNewRow.getElementsByTagName('td')[i].appendChild(a2);
|
oNewRow.getElementsByTagName('td')[i].appendChild(a2);
|
||||||
|
|
||||||
//Load DatePicker Trigger
|
//Load DatePicker Trigger
|
||||||
datePicker4("", newID, attributes.mask, attributes.start, attributes.end, attributes.time);
|
datePicker4("", newID, attributes.mask, attributes.start, attributes.end, attributes.time);
|
||||||
if(defaultValue=='today'){
|
|
||||||
attributesValue = elementAttributesNS(aObjects[0], '');
|
|
||||||
aObjects[n].value=attributesValue.value;
|
|
||||||
}else
|
|
||||||
aObjects[n].value = defaultValue;
|
aObjects[n].value = defaultValue;
|
||||||
}else{
|
}else{
|
||||||
if (_BROWSER.name == 'msie' && aObjects.length==1){ //Clone new input element if browser is IE
|
if (_BROWSER.name == 'msie' && aObjects.length==1){ //Clone new input element if browser is IE
|
||||||
var oNewOBJ = this.cloneInput(aObjects[n]);
|
var oNewOBJ = this.cloneElement(aObjects[n]);
|
||||||
oNewOBJ.value = defaultValue;
|
oNewOBJ.value = defaultValue;
|
||||||
var parentGG = aObjects[n].parentNode;
|
var parentGG = aObjects[n].parentNode;
|
||||||
parentGG.removeChild(aObjects[n]);
|
parentGG.removeChild(aObjects[n]);
|
||||||
parentGG.appendChild(oNewOBJ);
|
parentGG.appendChild(oNewOBJ);
|
||||||
}else{
|
}else{
|
||||||
if ((attributes.gridtype) && (attributes.gridtype=='currency')) {
|
if ((attributes.gridtype) && attributes.gridtype == "currency") {
|
||||||
var attributesCurrency = elementAttributesNS(aObjects[0], '');
|
var attributesCurrency = elementAttributesNS(aObjects[n], "");
|
||||||
aObjects[n].value = attributesCurrency.value.replace(/[.,0-9\s]/g,'');;
|
aObjects[n].value = attributesCurrency.value.replace(/[.,0-9\s]/g, "");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
aObjects[n].value = defaultValue;
|
aObjects[n].value = defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'checkbox': //CHECKBOX
|
case 'checkbox': //CHECKBOX
|
||||||
if (_BROWSER.name != 'msie'){
|
var attributeCheckBox = elementAttributesNS(aObjects[n], "");
|
||||||
attributesFalse = elementAttributesNS(aObjects[0], '');
|
|
||||||
if((defaultValue === attributesFalse.falsevalue) || (defaultValue===''))
|
if (defaultValue == "" || (typeof attributeCheckBox.falseValue != "undefined" && defaultValue == attributeCheckBox.falseValue) || (typeof attributeCheckBox.falsevalue != "undefined" && defaultValue == attributeCheckBox.falsevalue)) {
|
||||||
aObjects[n].checked = false;
|
aObjects[n].checked = false;
|
||||||
else
|
} else {
|
||||||
aObjects[n].checked = true;
|
aObjects[n].checked = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -414,6 +472,8 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
case 'textarea': //TEXTAREA
|
case 'textarea': //TEXTAREA
|
||||||
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');
|
aObjects = oNewRow.getElementsByTagName('td')[i].getElementsByTagName('textarea');
|
||||||
if (aObjects){
|
if (aObjects){
|
||||||
|
aObjects[0].className = "module_app_input___gray";
|
||||||
|
|
||||||
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
newID = aObjects[0].id.replace(/\[1\]/g, '\[' + currentRow + '\]');
|
||||||
aObjects[0].id = newID;
|
aObjects[0].id = newID;
|
||||||
aObjects[0].name = newID;
|
aObjects[0].name = newID;
|
||||||
@@ -623,38 +683,44 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
this.deleteGridRow = function (sRow, bWithoutConfirm)
|
||||||
this.deleteGridRow = function(sRow, bWithoutConfirm){
|
{
|
||||||
if (typeof bWithoutConfirm == 'undefined') bWithoutConfirm = false;
|
if (typeof bWithoutConfirm == "undefined") {
|
||||||
//var i, iRow, iRowAux, oAux, ooAux;
|
bWithoutConfirm = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.oGrid.rows.length == 3) {
|
if (this.oGrid.rows.length == 3) {
|
||||||
new leimnud.module.app.alert().make({
|
new leimnud.module.app.alert().make({
|
||||||
label: G_STRINGS.ID_MSG_NODELETE_GRID_ITEM
|
label: G_STRINGS.ID_MSG_NODELETE_GRID_ITEM
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bWithoutConfirm) {
|
if (bWithoutConfirm) {
|
||||||
this.deleteRowWC(this, sRow);
|
this.deleteRowWC(this, sRow);
|
||||||
} else {
|
} else {
|
||||||
new leimnud.module.app.confirm().make({
|
new leimnud.module.app.confirm().make({
|
||||||
label: G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
|
label: G_STRINGS.ID_MSG_DELETE_GRID_ITEM,
|
||||||
action : function() {
|
action: function ()
|
||||||
|
{
|
||||||
this.deleteRowWC(this, sRow);
|
this.deleteRowWC(this, sRow);
|
||||||
}.extend(this)
|
}.extend(this)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deleteRowWC = function(oObj, aRow){
|
this.deleteRowWC = function (oObj, aRow)
|
||||||
sRow = new String(aRow);
|
{
|
||||||
sRow = sRow.replace('[', '');
|
var sRow = new String(aRow);
|
||||||
sRow = sRow.replace(']', '');
|
sRow = sRow.replace("[", "");
|
||||||
iRow = Number(sRow);
|
sRow = sRow.replace("]", "");
|
||||||
|
var iRow = Number(sRow);
|
||||||
deleteRowOnDynaform(oObj, iRow);
|
var iRowAux = iRow + 1;
|
||||||
var lastItem = oObj.oGrid.rows.length - 2;
|
var lastItem = oObj.oGrid.rows.length - 2;
|
||||||
|
|
||||||
iRowAux = iRow + 1;
|
deleteRowOnDynaform(oObj, iRow);
|
||||||
|
|
||||||
while (iRowAux <= (lastItem)) {
|
while (iRowAux <= (lastItem)) {
|
||||||
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
for (i = 1; i < oObj.oGrid.rows[iRowAux - 1].cells.length; i++) {
|
||||||
var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i];
|
var oCell1 = oObj.oGrid.rows[iRowAux - 1].cells[i];
|
||||||
@@ -668,6 +734,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
aObjects1[0].checked = aObjects2[0].checked;
|
aObjects1[0].checked = aObjects2[0].checked;
|
||||||
}
|
}
|
||||||
aObjects1[0].value = aObjects2[0].value;
|
aObjects1[0].value = aObjects2[0].value;
|
||||||
|
aObjects1[0].className = aObjects2[0].className;
|
||||||
}
|
}
|
||||||
|
|
||||||
aObjects = oCell1.getElementsByTagName('div');
|
aObjects = oCell1.getElementsByTagName('div');
|
||||||
@@ -712,6 +779,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
aObjects1[0].options[j] = optn;
|
aObjects1[0].options[j] = optn;
|
||||||
}
|
}
|
||||||
aObjects1[0].value = vValue;
|
aObjects1[0].value = vValue;
|
||||||
|
aObjects1[0].className = aObjects2[0].className;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '<texta':
|
case '<texta':
|
||||||
@@ -719,6 +787,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
aObjects2 = oCell2.getElementsByTagName('textarea');
|
aObjects2 = oCell2.getElementsByTagName('textarea');
|
||||||
if (aObjects1 && aObjects2) {
|
if (aObjects1 && aObjects2) {
|
||||||
aObjects1[0].value = aObjects2[0].value;
|
aObjects1[0].value = aObjects2[0].value;
|
||||||
|
aObjects1[0].className = aObjects2[0].className;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -733,22 +802,30 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
}
|
}
|
||||||
iRowAux++;
|
iRowAux++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Delete row
|
||||||
this.oGrid.deleteRow(lastItem);
|
this.oGrid.deleteRow(lastItem);
|
||||||
|
|
||||||
for (i=0; i < this.aFields.length; i++){
|
var i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i <= this.aFields.length - 1; i++) {
|
||||||
this.aElements.pop();
|
this.aElements.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Recalculate functions if are declared
|
||||||
|
var element;
|
||||||
|
|
||||||
if (oObj.aFunctions.length > 0) {
|
if (oObj.aFunctions.length > 0) {
|
||||||
for (i = 0; i < oObj.aFunctions.length; i++) {
|
for (i = 0; i <= oObj.aFunctions.length - 1; i++) {
|
||||||
oAux = document.getElementById('form[' + oObj.sGridName + '][1][' + oObj.aFunctions[i].sFieldName + ']');
|
element = document.getElementById("form[" + oObj.sGridName + "][1][" + oObj.aFunctions[i].sFieldName + "]");
|
||||||
if (oAux) {
|
|
||||||
|
if (element) {
|
||||||
switch (oObj.aFunctions[i].sFunction) {
|
switch (oObj.aFunctions[i].sFunction) {
|
||||||
case 'sum':
|
case "sum":
|
||||||
oObj.sum(false, oAux);
|
oObj.sum(false, element);
|
||||||
break;
|
break;
|
||||||
case 'avg':
|
case "avg":
|
||||||
oObj.avg(false, oAux);
|
oObj.avg(false, element);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -763,36 +840,41 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
this.assignFunctions = function(aFields, sEvent, iRow) {
|
this.assignFunctions = function (aFields, sEvent, iRow)
|
||||||
iRow = iRow || 1;
|
{
|
||||||
var i, j, oAux;
|
var element;
|
||||||
for (i = 0; i < aFields.length; i++) {
|
var i = 0;
|
||||||
j = iRow;
|
var j = 0;
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + aFields[i].sFieldName + ']')) {
|
|
||||||
switch (aFields[i].sFunction) {
|
for (j = 0; j <= aFields.length - 1; j++) {
|
||||||
case 'sum':
|
i = iRow || 1;
|
||||||
leimnud.event.add(oAux, sEvent, {
|
|
||||||
|
while ((element = document.getElementById("form[" + this.sGridName + "][" + i + "][" + aFields[j].sFieldName + "]"))) {
|
||||||
|
switch (aFields[j].sFunction) {
|
||||||
|
case "sum":
|
||||||
|
leimnud.event.add(element, sEvent, {
|
||||||
method: this.sum,
|
method: this.sum,
|
||||||
instance: this,
|
instance: this,
|
||||||
event: true
|
event: true
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'avg':
|
case "avg":
|
||||||
leimnud.event.add(oAux, sEvent, {
|
leimnud.event.add(element, sEvent, {
|
||||||
method: this.avg,
|
method: this.avg,
|
||||||
instance: this,
|
instance: this,
|
||||||
event: true
|
event: true
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
leimnud.event.add(oAux, sEvent, {
|
leimnud.event.add(element, sEvent, {
|
||||||
method : aFields[i].sFunction,
|
method: aFields[j].sFunction,
|
||||||
instance: this,
|
instance: this,
|
||||||
event: true
|
event: true
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j++;
|
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -882,7 +964,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
i = 1;
|
i = 1;
|
||||||
fTotal = 0;
|
fTotal = 0;
|
||||||
aAux[2] = aAux[2].replace(']', '');
|
aAux[2] = aAux[2].replace(']', '');
|
||||||
while (oAux = this.getElementByName(i, aAux[2])) {
|
while ((oAux = this.getElementByName(i, aAux[2]))) {
|
||||||
if ( oAux.value() != "" ) {
|
if ( oAux.value() != "" ) {
|
||||||
fTotal += parseFloat(G.getValue(oAux.value().trim() ));
|
fTotal += parseFloat(G.getValue(oAux.value().trim() ));
|
||||||
}
|
}
|
||||||
@@ -916,19 +998,24 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
this.assignFormulas = function(aFields, sEvent, iRow) {
|
this.assignFormulas = function (aFields, sEvent, iRow)
|
||||||
iRow = iRow || 1;
|
{
|
||||||
var i, j, oAux;
|
var element;
|
||||||
for (i = 0; i < aFields.length; i++) {
|
var i = 0
|
||||||
j = iRow;
|
var j = 0;
|
||||||
while (oAux = document.getElementById('form[' + this.sGridName + '][' + j + '][' + aFields[i].sDependentOf + ']')) {
|
|
||||||
leimnud.event.add(oAux, sEvent, {
|
for (j = 0; j <= aFields.length - 1; j++) {
|
||||||
|
i = iRow || 1;
|
||||||
|
|
||||||
|
while ((element = document.getElementById("form[" + this.sGridName + "][" + i + "][" + aFields[j].sDependentOf + "]"))) {
|
||||||
|
leimnud.event.add(element, sEvent, {
|
||||||
method: this.evaluateFormula,
|
method: this.evaluateFormula,
|
||||||
instance: this,
|
instance: this,
|
||||||
args : [ oAux, aFields[i] ],
|
args: [element, aFields[j]],
|
||||||
event: true
|
event: true
|
||||||
});
|
});
|
||||||
j++;
|
|
||||||
|
i = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -1068,7 +1155,7 @@ var G_Grid = function(oForm, sGridName){
|
|||||||
* Dynaform - by Nyeke <erik@colosa.com
|
* Dynaform - by Nyeke <erik@colosa.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
deleteRowOnDybaform(this, iRow);
|
deleteRowOnDynaform(this, iRow);
|
||||||
|
|
||||||
iRowAux = iRow + 1;
|
iRowAux = iRow + 1;
|
||||||
while (iRowAux <= (this.oGrid.rows.length - 2)) {
|
while (iRowAux <= (this.oGrid.rows.length - 2)) {
|
||||||
|
|||||||
@@ -8,18 +8,27 @@ if( isset($request) ){
|
|||||||
switch($request){
|
switch($request){
|
||||||
case 'deleteGridRowOnDynaform':
|
case 'deleteGridRowOnDynaform':
|
||||||
//This code is to update the SESSION variable for dependent fields in grids
|
//This code is to update the SESSION variable for dependent fields in grids
|
||||||
|
|
||||||
|
if (!defined("XMLFORM_AJAX_PATH")) {
|
||||||
|
define("XMLFORM_AJAX_PATH", PATH_XMLFORM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($_SESSION[$_POST["formID"]][$_POST["gridname"]])) {
|
||||||
|
ksort($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
|
||||||
$oFields = array();
|
$oFields = array();
|
||||||
if (!defined('XMLFORM_AJAX_PATH')) define('XMLFORM_AJAX_PATH',PATH_XMLFORM);
|
|
||||||
ksort($_SESSION[$_POST['formID']][$_POST['gridname']]);
|
|
||||||
$initialKey = 1;
|
$initialKey = 1;
|
||||||
foreach ($_SESSION[$_POST['formID']][$_POST['gridname']] as $key => $value) {
|
|
||||||
if ($key != $_POST['rowpos']) {
|
foreach ($_SESSION[$_POST["formID"]][$_POST["gridname"]] as $key => $value) {
|
||||||
|
if ($key != $_POST["rowpos"]) {
|
||||||
$oFields[$initialKey] = $value;
|
$oFields[$initialKey] = $value;
|
||||||
$initialKey++;
|
$initialKey++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unset($_SESSION[$_POST['formID']][$_POST['gridname']]);
|
|
||||||
$_SESSION[$_POST['formID']][$_POST['gridname']] = $oFields;
|
unset($_SESSION[$_POST["formID"]][$_POST["gridname"]]);
|
||||||
|
|
||||||
|
$_SESSION[$_POST["formID"]][$_POST["gridname"]] = $oFields;
|
||||||
|
}
|
||||||
|
|
||||||
/* if( isset($_SESSION['APPLICATION']) ){
|
/* if( isset($_SESSION['APPLICATION']) ){
|
||||||
G::LoadClass('case');
|
G::LoadClass('case');
|
||||||
|
|||||||
@@ -3351,8 +3351,12 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
|||||||
if ($c == $therow){
|
if ($c == $therow){
|
||||||
$xValues[$therow] = $aRow;
|
$xValues[$therow] = $aRow;
|
||||||
} else {
|
} else {
|
||||||
|
if (is_array($aRow)) {
|
||||||
foreach ($aRow as $key => $value){
|
foreach ($aRow as $key => $value){
|
||||||
$xValues[$c][$key] = '';
|
$xValues[$c][$key] = "";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3396,18 +3400,25 @@ class XmlForm_Field_Grid extends XmlForm_Field
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the columns for rows and rows to columns
|
* Change the columns for rows and rows to columns
|
||||||
* @param <array> $values
|
* @param <array> $arrayData
|
||||||
* @return <array>
|
* @return <array>
|
||||||
*/
|
*/
|
||||||
function flipValues($values) {
|
public function flipValues($arrayData)
|
||||||
|
{
|
||||||
$flipped = array();
|
$flipped = array();
|
||||||
foreach ( $values as $rowKey => $row ) {
|
|
||||||
foreach ( $row as $colKey => $cell ) {
|
foreach ($arrayData as $rowIndex => $rowValue) {
|
||||||
if (! isset ( $flipped [$colKey] ) || ! is_array ( $flipped [$colKey] ))
|
if (is_array($rowValue)) {
|
||||||
$flipped [$colKey] = array ();
|
foreach ($rowValue as $colIndex => $colValue) {
|
||||||
$flipped [$colKey] [$rowKey] = $cell;
|
if (!isset($flipped[$colIndex]) || !is_array($flipped[$colIndex])) {
|
||||||
|
$flipped[$colIndex] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$flipped[$colIndex][$rowIndex] = $colValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $flipped;
|
return $flipped;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3698,6 +3709,10 @@ class XmlForm_Field_Date extends XmlForm_Field_SimpleText
|
|||||||
$mask = '%Y-%m-%d'; //set default
|
$mask = '%Y-%m-%d'; //set default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->defaultValue == "today") {
|
||||||
|
$defaultValue = masktophp($mask);
|
||||||
|
}
|
||||||
|
|
||||||
if( strpos($mask, '%') === false ) {
|
if( strpos($mask, '%') === false ) {
|
||||||
if( strpos($mask, '-') !== false )
|
if( strpos($mask, '-') !== false )
|
||||||
$separator = '-';
|
$separator = '-';
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
{if ($form->addRow) }
|
{if ($form->addRow) }
|
||||||
<table class='Record'>
|
<table class='Record'>
|
||||||
<tr><td></td>
|
<tr><td></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>
|
<td><img id="form[{$form->name}][bullet]" src="/images/bulletButton.gif" /> <a id="form[{$form->name}][addLink]" class="GridLink" href="javascript:;" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow(); return false;">{$form->NewLabel}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<td style="white-space:nowrap;">{$field->field}</td>
|
<td style="white-space:nowrap;">{$field->field}</td>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{if $form->deleteRow == '1' }
|
{if $form->deleteRow == '1' }
|
||||||
<td align="center"><A class="GridLink" href="#" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]');return false;">{$form->DeleteLabel}</A> </td>
|
<td align="center"><A class="GridLink" href="javascript:;" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]'); return false;">{$form->DeleteLabel}</A> </td>
|
||||||
{/if}
|
{/if}
|
||||||
{if ($form->editRow=='1')}
|
{if ($form->editRow=='1')}
|
||||||
<td>edit"{$form->editRow}"</td>
|
<td>edit"{$form->editRow}"</td>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
{if ($form->addRow) }
|
{if ($form->addRow) }
|
||||||
<table class='Record'>
|
<table class='Record'>
|
||||||
<tr><td></td>
|
<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 class="GridLink" href="javascript:;" value="Insert" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').addGridRow(); return false;">{$form->NewLabel}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
<td style="">{$field->field}</td>
|
<td style="">{$field->field}</td>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
{if $form->deleteRow == '1' }
|
{if $form->deleteRow == '1' }
|
||||||
<td align="center"><A class="GridLink" href="#" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]');return false;">{$form->DeleteLabel}</A> </td>
|
<td align="center"><A class="GridLink" href="javascript:;" onclick="form_{$form->owner->id}.getElementByName('{$form->name}').deleteGridRow('[{literal}{$smarty.section.row.index+1}{/literal}]'); return false;">{$form->DeleteLabel}</A> </td>
|
||||||
{/if}
|
{/if}
|
||||||
{if ($form->editRow=='1')}
|
{if ($form->editRow=='1')}
|
||||||
<td>edit"{$form->editRow}"</td>
|
<td>edit"{$form->editRow}"</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user