私の答えは、この質問に基づいています.Table row and column number in jQueryの功績です。
これを次のように試してください:
Javascript:
<script>
function OnDataBound() {
// #Grid needs to match the name of the grid in View's markup.
$('#Grid table td').click(function () {
var col = $(this).parent().children().index($(this));
var row = $(this).parent().parent().children().index($(this).parent());
alert('Row: ' + row + ', Column: ' + col);
});
//As a side note, you can get at the contents of the row selected with
//something along these lines:
//(this will not work unless you substitute the "EmployeeId" id with a valid one from your model.
$('#Grid table tr').dblclick(function () {
alert($(this).find("span[id=EmployeeId]")[0].innerText); //EmployeeId is just a column name used for example purposes.
});
}
</script>
グリッド マークアップ:
@(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
//columns & bound
})
.ClientEvents(e=> e.OnDataBound("OnDataBound")) // This changed to a OnDataBound event.