Menu Close

Javascript / CSS

In answers, as a list view, remove some columns and change the order of others

The code:

$(function () {

  // Column number from: column number to move it before
  const colToMoveFromBeforeCol = {
    9: 8,
    7: 5,
  };

  // Colum numbers to remove
  const colToRemove = [0,1,2];

  $("#survey-answers-list tr").each(function () {
    const $thisRow = $(this);
    Object.entries(colToMoveFromBeforeCol).forEach(([fromNb, toNb]) => {
      const $fromCell = $thisRow.find("td, th").eq(fromNb);
      const $toCell = $thisRow.find("td, th").eq(toNb);
      if ($fromCell.length && $toCell.length) {
        $fromCell.detach().insertBefore($toCell);
      }
    });
    colToRemove.forEach(colNb => {
        $thisRow.find("td, th").eq(colNb).hide();
    });
  });
});

Add it in the survey advanced settings here:

Before:

After: