Expand my Community achievements bar.

SOLVED

Problem wtih a table

Avatar

Level 1

Hi,

sorry for my bad English.

I have a problem with a table. I have done a table with some script but when I add a new line, this script don't work in the new line or lines. I know I have something wrong but I don't know the solution. Can anyboy help me? You can see the file in http://www.frmgm.jazztel.es/duda.pdf. I am new in the programming matter.

Thank so much.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Ok now I understand ......each row that you add to the table changes the somExpression for the objects (so that they are unique). The repeating subform gets an occurance number but the rest of the expression remains the same. If you do not include an occurance number then the 1st occurance is assumed ...that is why only the 1st row is affected. You will have to construct the expressions so that you can derive the correct occurance number. The click event code would look like this:

if (xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación1.rawValue == "0") {
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación2.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación3.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación4.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").Botón1.presence = "hidden";
  } else {
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").Botón1.presence = "visible";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación1.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación2.access = "open";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación3.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación4.access = "readOnly";
    }

You can see that the xfa.resolveNode accepts a string representing the object that we want to use. The string is then constructed and the occurance number of the Fila1 subform is derived by getting the index number of the parent subform of the object that we have clicked (this.parent.index). Occurane numbers are wrapped in square brackets [].  The rest has not changed. You will have to update all of your code to use this technique.

Hope that helps

Paul

View solution in original post

5 Replies

Avatar

Former Community Member

I am not sure I understand what the problem is .....are you saying you cannot add lines to the table?

Paul

Avatar

Level 1

Hi. I can add line or lines but when I add line the script don't work in the new line or lines. For example, in the first line if the firts check box don't be select the second check box can't be select but when I add a new line this script don't work. I hope the explanation was correct.

Thank you so much.

Avatar

Correct answer by
Former Community Member

Ok now I understand ......each row that you add to the table changes the somExpression for the objects (so that they are unique). The repeating subform gets an occurance number but the rest of the expression remains the same. If you do not include an occurance number then the 1st occurance is assumed ...that is why only the 1st row is affected. You will have to construct the expressions so that you can derive the correct occurance number. The click event code would look like this:

if (xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación1.rawValue == "0") {
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación2.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación3.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación4.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").Botón1.presence = "hidden";
  } else {
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").Botón1.presence = "visible";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación1.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación2.access = "open";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación3.access = "readOnly";
  xfa.resolveNode("Tabla1.Fila1[" + this.parent.index + "]").CasillaVerificación4.access = "readOnly";
    }

You can see that the xfa.resolveNode accepts a string representing the object that we want to use. The string is then constructed and the occurance number of the Fila1 subform is derived by getting the index number of the parent subform of the object that we have clicked (this.parent.index). Occurane numbers are wrapped in square brackets [].  The rest has not changed. You will have to update all of your code to use this technique.

Hope that helps

Paul

Avatar

Level 1

Thank you very much. But I have another questions about table. Now the script work correctly in the new lines but is possible to say that the script don't work in old lines and only work in the new line created?

Best regards.

Avatar

Former Community Member

When we add a line we know that the index of the row we are working on woudl be the count of subforms - 1 (the occurances are 0 based). If there is code between objects then you have to figure out which row you are on so instead of getting a count for the index you need to find a way to get the index of the row you want to affect. In most cases an object from the same row is used to trigger the code so you can use this.parent.index to get the occurance of the parent node.

Then you need to modify your object references to include the indexes (like my code does) but instead of using the count you woudl use the index that you derived.

Make sense?

Paul

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----