Expand my Community achievements bar.

SOLVED

Query about script.

Avatar

Level 3

Dear All.

Following codes are used in the form.

It can add row through "Add Row" button on the top of table, and can delete row through "x" button in the first of column.

When the row is added by "Add Row" button, the number in the first column is increased automatically as Pic1.

But when I click the "x" button to delete row, the number is still remained as before deleting row (Pic2).

I want to refresh digit in the first column after deleting row.

How can I control this issue?

Thanks.

--------------------------- Add Row code -----------------------------------

var nNodes = Test_Result1.sub_Product_accessories.Config_Acc.resolveNodes("Config_Acc[*]").length;
if (nNodes < 15){
  Test_Result1.sub_Product_accessories.Config_Acc.instanceManager.addInstance();
};

--------------------------- Delete Row code -----------------------------------

var nNodes = Test_Result1.sub_Product_accessories.Config_Acc.resolveNodes("Config_Acc[*]").length;
   
if(nNodes > 1)
   Test_Result1.sub_Product_accessories.Config_Acc.instanceManager.removeInstance(this.parent.index);

Pic1 : Before delete row

asis.JPG

Pic 2 : After delete row

tobe.JPG

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi, The "_" is just an alternative syntax to using the instanceManager.  Any property referenced in the calculate event is added to a watch list, if any of those values change then the calculate event fires.  Line 1 is just referenceing a property that changes when a row is added/removed, it's only purpose is to trigger line 2 to execute.

Bruce

View solution in original post

3 Replies

Avatar

Level 10

Hi, Try the following script in the calculate event of the first column.  The first line might look redundant but it is needed to ensure the script is fired every time a table row is added.

var i = _Config_Acc.count;
parent.index+1;

Bruce

Avatar

Level 3

Hi Bruce.

Thank you for your respond to my query.

If you don't mind, could I ask you something about followings?

what does "_" meaning before Config_Acc.count in the line1.

and Relationship between line1 and line2, what do you have?

variable "i" never used in the line2. though, in case of deleting line1, this script doesn't work.

line1 : var i = _Config_Acc.count;
line2 : parent.index+1;

Thanks.

Avatar

Correct answer by
Level 10

Hi, The "_" is just an alternative syntax to using the instanceManager.  Any property referenced in the calculate event is added to a watch list, if any of those values change then the calculate event fires.  Line 1 is just referenceing a property that changes when a row is added/removed, it's only purpose is to trigger line 2 to execute.

Bruce