cellIndex
Returns the index of the specified table cell. Skips group and detail table cells.
Parameters
cell String|Element|jQuery
A string, DOM element or jQuery object which represents the table cell. A string is treated as a jQuery selector. If there are locked columns in the Grid, the jQuery object, representing the cell, must be passed as an argument.
Returns
Number
the index of the specified table cell.
Example - find the cell index when the cell is a jQuery object
<div id="grid"></div>
<script>
let encode = kendo.htmlEncode;
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 },
],
detailTemplate: ({ name, age }) => `<div>Name: ${encode(name)}</div><div>Age: ${encode(age)}</div>`
});
var grid = $("#grid").data("kendoGrid");
var cell = $("#grid td:eq(1)");
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(grid.cellIndex(cell));
</script>
Example - find the cell index when the cell is a string
<div id="grid"></div>
<script>
let encode = kendo.htmlEncode;
$("#grid").kendoGrid({
columns: [
{ field: "name" },
{ field: "age" }
],
dataSource: [
{ name: "Jane Doe", age: 30 },
{ name: "John Doe", age: 33 },
],
detailTemplate: ({ name, age }) => `<div>Name: ${encode(name)}</div><div>Age: ${encode(age)}</div>`
});
var grid = $("#grid").data("kendoGrid");
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(grid.cellIndex("td:eq(1)"));
</script>