Answer:
We can achieve this by using the native mouse double-click event on the Gantt element. Please refer to the below code snippet,
<SfGantt
//……
< <GanttEvents TValue="GanttDataSource" Created="created">GanttEvents>
@code{
[Inject]
IJSRuntime JsRuntime { get; set; }
public async void created(object args)
{
await JsRuntime.InvokeAsync("clickAction", args);
}
}
[_host.cshtml]
<body>
//…
<script src="~/custom.js">script>
body>
[custom.js]
function clickAction(args) {
var ganttObj = document.getElementById("GanttSample").ej2_instances[0];
ganttObj.element.addEventListener("dblclick", function (e) {
debugger;
var index =
e.target.cellIndex;
var field =
ganttObj.columns[index].field;
alert(field + " Clicked");
});
} |
Find the sample to add a click event to a Blazor Gantt Chart column from
here.