Traversing through cells in a single column

Tags: #<Tag:0x00007efc6247e950>

I have 7 columns, and I want to perform a traversal on 5th column such that, at each row of that column, there is a function operation performed on it and the data gets immediately updated right there. This code basically checks the cell, if the data value is ‘<0’ then it gives “X”, if it is ‘==0’ it gives “O”, if it is ==1 it gives 1, if it is ==2 it gives 2, if it is ==3 it gives 3. I am having lot of difficulties, anyone can understand and help out?

columnSummary: [
			{
				sourceColumn: 5,
				type: 'rank',
				destinationRow: 0,
				destinationColumn: 5,
				rank(endpoint) {
					const hotInstance = this.hot;
					const checkRange = rowRange => {
					let i = rowRange[1] || rowRange[0];
					let counter = 0;
					do {
						if (parseInt(hotInstance.getDataAtCell(i, endpoint.sourceColumn)) < 0) {
						return "X";
						counter++;
						}
						else {
							return "O";
							if(parseInt(hotInstance.getDataAtCell(i, endpoint.sourceColumn)) == 1) {
							return 1;
							}
							else if (parseInt(hotInstance.getDataAtCell(i, endpoint.sourceColumn)) == 2) {
							return 2;
							}
							else if (parseInt(hotInstance.getDataAtCell(i, endpoint.sourceColumn)) == 3) {
							return 3;
							}
						}
						i--;
					}while (i >= rowRange[0]);
					}
				}
			}
	]

Hi @param556

While I was checking your code I get this error:

"One of the Column Summary plugins' destination points you provided is beyond the table boundaries!"

Can you please send me a working example in jsFiddle?

Hi @adrian.szymanski that is the same error I am encountering. Unfortunately I had to rewrite the code using PHP approach (which worked, but I want to know this approach too). Also I might not be able to upload the code entirety on Fiddle, but I can sample it to an example. Would that be fine?

Yes, we can try this way.

Hi @param556

were you able to test the code on Fiddle? If not I also recommend Replit. It’s easier to import dependencies.