3

I need to hide the parent node's checkbox (Boolean cell) in the tree List. I use DevExpress with jQuery. I am new to this tech. Kindly anyone help me out to solve this problem with efficient way.

I have searched for the solutions through the internet. If I implement them, I have to restructure my saving mechanism of the dxTreeList. I used the built-in checkbox (Boolean cell), but the resources say to use the cell template with custom checkbox.

My code implementation:

dataSource: dataForControls,
id: "id",
parentId: "parentId",
editing: {
   mode: "batch",
   allowAdding: false,
   allowUpdating: true,
   allowDeleting: false,
},
columns: [
   { dataField: "pageName", caption: "Page / Control", allowEditing: false },
   { dataField: "pageAccess", caption: "Has Access", allowEditing: true, dataType: "boolean",
}
]

I need to hide the checkbox of the parent node.

0

1 Answer 1

1

You can use cellTemplate option to achieve your goal. do it like below:

$("#treeList").dxTreeList({
  dataSource: dataForControls,
  keyExpr: "id",
  parentIdExpr: "parentId",
  editing: {
    mode: "batch",
    allowUpdating: true,
    allowAdding: false,
    allowDeleting: false
  },
  columns: [
    { dataField: "pageName", caption: "Page / Control", allowEditing: false },
    {
      dataField: "pageAccess",
      caption: "Has Access",
      dataType: "boolean",
      allowEditing: true,
      cellTemplate: function(container, options) {
        const isLeaf = !options.row.isNewRow && !options.node.hasChildren; // only for leaf nodes
        if (isLeaf) {
          $("<div>")
            .addClass("dx-checkbox")
            .appendTo(container)
            .dxCheckBox({
              value: options.value,
              onValueChanged(e) {
                options.setValue(e.value);
              }
            });
        }
      }
    }
  ]
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.