KendoUI Grid Checkbox click event

21,019

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');
        }

    });
Share:
21,019
Tulips
Author by

Tulips

A programmer and currently working on web technologies. Moved to the Alps region from North America a few years ago and loving the nature. Going back to America soon!

Updated on August 05, 2022

Comments

  • Tulips
    Tulips almost 2 years

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

    )