Skip to content

Instantly share code, notes, and snippets.

@tomysmile
Last active November 28, 2020 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomysmile/3aafc08138df762c7d79543b8cb0e377 to your computer and use it in GitHub Desktop.
Save tomysmile/3aafc08138df762c7d79543b8cb0e377 to your computer and use it in GitHub Desktop.
how to disable and prevent selection on root node in devexpress treelist (angular)
onCellPrepared(e) {
if (
e.rowType === "data" &&
e.column.visibleIndex === 0 &&
e.value === "ROOT"
) {
const el = e.cellElement as HTMLElement;
const ck = el.getElementsByClassName("dx-select-checkbox")[0];
const instance = dxCheckBox.getInstance(ck);
instance.option("disabled", true);
}
}
onSelectionChanged(e) {
// disable root node
const disabledKeys = e.selectedRowsData
.filter((i) => i.root === true)
.map((p) => p._id);
if (disabledKeys.length > 0) {
e.component.deselectRows(disabledKeys);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment