Hi,
I have a grid that uses (Y&X axis)data from an API(json) and the first column always needs to be non-selectable(left or rightclick, keyboard) same as the header which is already non-selectable.
selectOptions: SelectionSettingsModel = { cellSelectionMode: 'Box', type: 'Multiple', mode: 'Cell' };
In short: Is there a easy way to prevent the user from selecting any cells(in anyway) in a specific column(in my case the first column aka 0)?
Thank you in advance!
|
// Grid’s cellSelecting event handler
onCellSelecting(args) {
// Retrieves current row and column information from the target element
let curRowInfo = this.grid.getRowInfo(args.currentCell);
if (curRowInfo.column.field === 'CustomerName') {
// Cell selection is cancelled if the column is ‘CustomerName’
args.cancel = true
}
} |
Hi,
Ah, I see that i used a wrong statement in my question. "in anyway" -> "every possible way".
Your answer prevents the user from clicking on the cell, but in my scenario the cell should not be selectable in every possible scenario which I mentioned earlier: "left or rightclick, keyboard".
-In the first case scenario this means click should not be possible (your example works for that), but that also means that the user cannot make a box selection(starting outside & holding down mouse) with his/her mouse. And that doesn't work in your example, since that example(this.grid.getRowInfo()) only checks the initial column.
-In the last case scenario this means that holding down shift with directional keys to select multiple cells should also not work in that column(also starting outside that column).
In short: the column needs to be fully ignored when it comes to every possible selection that the user can make.
|
<e-column field='CustomerName' [customAttributes]='customAttributes'></e-column> |
|
public ngOnInit(): void {
this.customAttributes = { class: 'custom_style' };
} |
|
.custom_style {
background-color: white !important;
} |