Get specific row and cell index in Grid

17 Feb 20221 minute to read

You can get the specific row and cell index of the grid by using rowSelected event of the grid. Here, we can get the row and cell index by using aria-rowindex(get row Index from tr element) and aria-colindex(column index from td element) attribute.

<ejs-grid id="Grid" dataSource="@ViewBag.DataSource" rowSelected="rowSelected">
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
        <e-grid-column field="CustomerID" headerText="Customer ID" type="string" width="120"></e-grid-column>
        <e-grid-column field="Freight" headerText="Freight" textAlign="Right" format="C2" editType="numericedit" width="120"></e-grid-column>
        <e-grid-column field="ShipCountry" headerText="Ship Country" width="150" editType='dropdownedit'></e-grid-column>

    function rowSelected(args) {
        alert("row index: " + args.row.getAttribute('aria-rowindex'));
        alert("column index: " +'aria-colindex'));
public IActionResult Index()
    ViewBag.DataSource = OrderDetails.GetAllRecords();
    return View();