ce icon indicating copy to clipboard operation
ce copied to clipboard

User can set a non-topleft cells' value of a merged area, and the value retains after the merging is removed.

Open StephenChips opened this issue 4 years ago • 0 comments

version

v4.7.3

expectation

If a cell's merged, it shouldn't have any value, unless it is the top left cell of the merged area (let's call it as "master cell"), in which case it represent the merged cell's value, or it can have value, but that should be equals to the "master cell". Anyhow, after I remove the merging, it should become blank, as the UI actually shows.

reproduce code

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
  </head>
  <body>
    <script src="lib/jexcel.js"></script>
    <script src="lib/jsuites.js"></script>
    <link rel="stylesheet" href="lib/jsuites.css" type="text/css" />
    <link rel="stylesheet" href="lib/jexcel.css" type="text/css" />

    <div id="spreadsheet"></div>

    <script>
      var data = [
        [],
        ["Jazz", "Honda", "2019-02-12", "", true, "$ 2.000,00", "#777700"],
        ["Civic", "Honda", "2018-07-11", "", true, "$ 4.000,01", "#007777"],
      ];

      const a = jspreadsheet(document.getElementById("spreadsheet"), {
        data: data,
        columns: [
          { type: "text", title: "Car", width: 120 },
          {
            type: "dropdown",
            title: "Make",
            width: 200,
            source: ["Alfa Romeo", "Audi", "Bmw"],
          },
          { type: "calendar", title: "Available", width: 200 },
          { type: "image", title: "Photo", width: 120 },
          { type: "checkbox", title: "Stock", width: 80 },
          {
            type: "numeric",
            title: "Price",
            width: 100,
            mask: "$ #.##,00",
            decimal: ",",
          },
          { type: "color", width: 100, render: "square" },
        ]
      });

      /* End of initializtion */

      a.setMerge('A1', 2, 2);
      a.setValue('A1', 1);
      a.setValue('A2', 1);

      let a1 = a.getValue("A1");
      let a2 = a.getValue("A2");
      console.log(a1, a2); // print 1 1

      a.removeMerge("A1");
      
      a1 = a.getValue("A1");
      a2 = a.getValue("A2");
      console.log(a1, a2); // printed 1 1

      /* But cell A2 is empty as UI shows after the merge's removed */
    </script>
  </body>
</html>

StephenChips avatar Jun 17 '21 05:06 StephenChips