Last active
November 28, 2020 10:15
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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