KendoUI Grid Click Event

I have data that will be displayed in the KendoUI grid. There are some boolean data, and I want them to display as flags. Also, when the user clicks the checkbox, I need to do something, so I need the onclick event for each row of data. How to do it in the KendoUI grid? How can I give each flag a different name and trigger onclick events? My code is:

@(Html.Kendo().Grid((IList<M.TS.DomainModel.C>)ViewData["peoplefind"]) .Name("Grid") .Columns(columns => { columns.Bound(p => p.FirstName); columns.Bound(p => p.LastName); columns.Bound(p => p.User).Title("Email"); columns.Bound(p => p.City); columns.Bound(p => p.TimeStamp).Title("Testdate").Format("{0:MM/dd/yyyy}"); columns.Command(command => command.Custom("Info").Click("showDetails")).Title("Info"); columns.Bound(p => p.CheckOK).ClientTemplate( "<input type='checkbox' value= '#= CheckOK #' " + "# if (CheckOK) { #" + "checked='checked'" + "# } #" + "/>" ); }) .Sortable() .Scrollable(scr => scr.Height(300)) .Groupable() .Selectable() .Pageable() .DataSource(dataSource => dataSource .Ajax() .PageSize(20) .ServerOperation(false)) .Resizable(resize => resize.Columns(true)) 

)

+4
source share
1 answer

OK, so I figured it out. I added class = 'c-ok' to the checkbox template and added the following code to get the click event.

  $('.c-ok').click(function (e) { if ($(this).is(':checked')) { alert('checked'); cokclick(); } else { alert('not checked'); } }); 
+4
source

Source: https://habr.com/ru/post/1500312/


All Articles