|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
...
})...Render()
<script type="text/javascript">
document.getElementById("Grid").addEventListener('click', function (e) {
//Here “aria-colindex” represents the column index and “index” represents the row index
if (e.target.classList.contains("e-rowcell") && ((e.target.getAttribute("aria-colindex") == "1") ||
(e.target.getAttribute("aria-colindex") == "2")) && e.target.getAttribute("index") == "2") {
alert("Clicked cell value is : " + e.target.innerHTML);
}
})</script> |
|
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col => {
...
}).SelectionSettings(sel=>sel.Mode(Syncfusion.EJ2.Grids.SelectionMode.Cell)).AllowSelection(true).CellSelecting("selecting").Render()
<script type="text/javascript">
function selecting(args) {
//Here “cellIndex” represents the column index and “rowIndex” represents the row index
if ((args.cellIndex.rowIndex == 4 && args.cellIndex.cellIndex == 1) || (args.cellIndex.rowIndex == 4 && args.cellIndex.cellIndex == 3)) {
alert(args.currentCell.innerHTML);
}
else
args.cancel = true;
}
</script> |