Transpose columns to rows

Hi everyone,

Is it possible to display information from the database in a list, but transposing the columns to rows?
Thank you.
Best
Bruno

I found the following for transposing a 2-dimensional array in JavaScript:

function transpose(original) {
    var copy = [];
    for (var i = 0; i < original.length; ++i) {
        for (var j = 0; j < original[i].length; ++j) {
            // Skip undefined values to preserve sparse array
            if (original[i][j] === undefined)
              continue;

            // Create row if it doesn't exist yet
            if (copy[j] === undefined)
              copy[j] = [];

            // Swap the x and y coordinates for the copy
            copy[j][i] = original[i][j];
        }
    }
    return copy;
}

console.log(transpose([
    [1,2,3],
    [4,5,6],
    [7,8,9]
]));

You may (most likely) will have to extrapolate the above for your purposes.

Hi abergquist ,

Sorry for the delay on the reply. Didn’t get the message notification.
Thank you. Will try.

Bruno

Did it work, bruno? I’m also trying to do the same thing!