Dynamic checkbox

Answered
vasantjk asked on February 9, 2022

Hi team,
I am facing a problem in creating checkbox in dynamic way.
The requirement is i am giving details of the value and conditions for making the checkbox checked and unchecked. 
Now the problem is its working if i create a new column but if i add for another the same process happens and the old one get erased and only new one i getting the checkbox.

pivot.current.flexmonster.customizeCell((cell, data) => {
      for (let i = 0; i < arraytemp.length; i++) {
        console.log("");
        let val = arraytemp[i].column;
        if (
          data.type !== "header" &&
          data.measure.uniqueName === val &&
        ) {
          cell.style["text-align"] = "center";
          cell.style["z-index"] = 2;
          cell.text = `<input value=${data.value} type="checkbox" class="myinput" >${data.value}`;
        }
else {
          return;
        }
      }
    });
  };

//////////////////////DATA/////////////////////
 
[{columnname:"checkbox1"},
{columnname:"checkbox2"}]
 
now if this is been executed the checkbox1 is not applied with check box only checkbox2 is applied 
help me with this requirement.

1 answer

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 11, 2022

Hello!

Thank you for raising a ticket.

Kindly note that the customizeCell(cell, data) function is applied to each cell separately every time the table is redrawn. The first parameter contains the representation of a single cell as an HTML element (like classes, styles, inner text). The second one is CellDataObject, and it contains detailed information about the data, stored in that cell (like measure, label, row/column index).

These parameters do not contain any details about other cells in the table, so we recommend conditionally customizing a cell based on the corresponding data. 

For more knowledge, please check these docs:
customizeCell - https://www.flexmonster.com/api/customizecell/.
CellDataObject - https://www.flexmonster.com/api/cell-object/.

After analyzing the described issue, we suggest you check the code for customizeCell and make sure that the algorithm is working according to your business logic.

Hope this information will help you to solve the issue. 

Best Regards,
Maksym

Please login or Register to Submit Answer