Hi
Kevin Hoffmann,
Yes, it is possible to disable sorting when clicking on the header text using a
JavaScript solution, while still allowing the column menu to function as
normal. Kindly refer to the code snippet and sample below for your reference.
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await RunTime.InvokeVoidAsync("disableSortingExceptColumnMenu",
"MyGrid");
}
}
JavaScript.js
function
disableSortingExceptColumnMenu(gridId) {
const grid =
document.getElementById(gridId);
if (!grid) return;
const headers =
grid.querySelectorAll('.e-headercell');
headers.forEach(header => {
header.addEventListener('click', function (e) {
const isColumnMenuClick = e.target.closest('.e-columnmenu');
if (!isColumnMenuClick) {
// Prevent sorting
e.stopPropagation();
e.preventDefault();
}
}, true);
});
};
|
Regards,
Prathap Senthil
Attachment:
DataGrid_7aa569cb.zip