<ejs-grid id="Grid" dataSource=" ViewBag.DataSource" dataBound="GridDataBound" allowPaging="true">
<e-grid-columns>
<e-grid-column field="OrderID" width="110" isPrimaryKey=true></e-grid-column>
<e-grid-column field="CustomerID" headerText="CustomerID" width="110" template="#nameAnchor"></e-grid-column>
<e-grid-column field="EmployeeID" headerText="EmployeeID" width="110"></e-grid-column>
<e-grid-column field="ShipCity" headerText="CustomerID" width="110"></e-grid-column>
</e-grid-columns>
</ejs-grid>
<div id="nameAnchor" style="display:none;" >
<a asp-area="" asp-controller="Home" asp-action="About" class="btn btn-default">${CustomerID}</a>
</div>
<script>
function GridDataBound(args) {
document.getElementsByClassName("e-grid")[0].addEventListener("click", (e) => {
if (event.target.classList.contains("btn-default")) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
var data = gridObj.getSelectedRecords()[0]['OrderID'];
event.target.setAttribute('rel='nofollow' href', '/Home/About/' + data);
}
});
}
</script> |