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



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)




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;