Get row cell index in Vue Treegrid component

16 Mar 20232 minutes to read

You can get the specific row and cell index of the Tree Grid by using rowSelected event of the treegrid. 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.

  <div id="app">
      <ejs-treegrid :dataSource="data" :treeColumnIndex="1" height='300px' idMapping='TaskID' parentIdMapping='parentID' :rowSelected='rowSelected' ref="treegrid">
          <e-column field="TaskID" headerText="Task ID" :isPrimaryKey='true' width="70" textAlign="Right"></e-column>
          <e-column field="TaskName" headerText="Task Name" width="100" ></e-column>
          <e-column field="StartDate" headerText="Start Date" format="yMd" width="100" textAlign="Right"></e-column>
          <e-column field="EndDate" headerText="End Date" width="100" format="yMd" textAlign="Right"></e-column>
          <e-column field="Duration" headerText="Duration" width="90" textAlign="Right"></e-column>
          <e-column field="Priority" headerText="Priority" width="90" textAlign="Left"></e-column>
import Vue from "vue";
import { TreeGridPlugin, Page } from "@syncfusion/ej2-vue-treegrid";
import { projectData } from "./datasource.js";

export default {
  data() {
    return {
      data: projectData,
  methods: {
    rowSelected(args) {
        alert("row index: "+args.row.getAttribute('aria-rowindex'));
        alert("column index: "'td').getAttribute('aria-colindex'));
  provide: {
    treegrid: [Page]