I have a grid and event like this. The text placed in a label in the last line of the script depends upon which of two columns got clicked; HomeAddress or BizAddress. .If the user clicked the Name column instead of one of the two address columns, I want to do nothing.
How can I tell that so I can pick which field to put in the label text?
How can I tell that so I can pick which field to put in the label text?
@(Html.Kendo().Grid<
AppUser
>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(c => c.Name).Width(140);
columns.Bound(c => c.HomeAddress).Width(140);
columns.Bound(c => c.BizAddress).Width(140);
})
.HtmlAttributes(new { style = "height: 380px;" })
.Scrollable()
.Groupable()
.Sortable()
.Selectable()
.Events(events => events.Change("grid_change"))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("FilteredPeople_Read", "UserConsoleViewModels"))
)
)
<
script
>
function grid_change(e) {
var data = this.dataItem(this.select());
if (clickedColumnIndex != 0) // How do I find selectedColumnIndex?
{
$("#labelName").text(data.Name);
$("#labelAddress").text(selectedColumnIndex == 1 ? data.HomeAddress : data.BizAddress);
}
}
</
script
>