Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KendoUI Grid Checkbox click event

I have data to be displayed in KendoUI grid. There is some boolean data and I want it to be displayed as check boxes. Also, when the user clicks the check box I need to do something so I need the onclick event for each row of data. How do I do this in KendoUI grid? How do I give each check box a different name and fire onclick events? My code:

 @(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))

)

like image 339
Tulips Avatar asked Sep 03 '13 13:09

Tulips


1 Answers

OK so I figured it out. I added class='c-ok' in the template of the check box 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');
        }

    });
like image 143
Tulips Avatar answered Nov 11 '22 14:11

Tulips