How split text and fill a dynamic table columns with the values inside the text?

Avatar

Avatar
Validate 1
Level 1
KareemGaber
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
KareemGaber
Level 1

Likes

0 likes

Total Posts

3 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
KareemGaber
Level 1

15-03-2020

I have a text that is a combination of values separated with commas "," and I want to split it and fill some column inside a table with those values.

I tried this code in the indexChange event of the table row:

var raw = this.EXTKD.rawValue.split(',');
this.EXTKD.rawValue = raw[this.index];

knowing that EXTKD is the name of the cell that I want to fill with the value, and it is intially filled with the whole text that I want to split.

when I try the above code only the first row gets filled.

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

17-03-2020

Ok, given your table has a repeatable row named "Row", you can use the following script in the calculate event of the table (not the row).

var oRows = this.resolveNodes("Row[*]"), // create a nodelist of the table rows
	aValues = [""], // array of values
	oRow, // reference object
	i; // counting variable

// If the table has at least one row
if (oRows.length > 0) {
	// Check every row
	for (i = 0; i < oRows.length; i += 1) {
		oRow = oRows.item(i); // set the current row ans reference object
		// if it is the first row, copy the data
		if (i === 0) {
			// check if the data field is empty. If not, create an array of from its value
			aValues = oRow.isNull ? aValues : oRow.EXTKD.rawValue.split(",");
		}
		// Set the data field value of the current row, exept there are more rows than entries in the array
		oRow.EXTKD.rawValue = i < aValues.length ? aValues[i] : oRow.EXTKD.rawValue;
	}
}