vendredi 11 novembre 2016

how to unable kendo grid checkbox?

In the code snippet is the example of grid, I would like to unable the checkbox in the grid when the remark have invalid value. In the code below will have 3 sample records. Output: The first and third checkbox set to unable, the second checkbox are enable to let user to select.

var userRecord=[{reason:"Invalid",UserName:"test"},
                 {reason:"",UserName:"test1"},
                 {reason:"Invalid2",UserName:"test2"}]

var grid=$("#grid").kendoGrid({
                columns: [
                { field: "", width: "40px", template: "<input name='Discontinued' class='checkbox' type='checkbox' />" },
                { field: "reason", title: "Remark" },
                { field: "UserName", title: "User Name" },


               ],
    dataSource: {
      data: userRecord
    },
      dataBound: function (e) {
        $(".checkbox").bind("change", function (e) {
          var grid = $("#grid").data("kendoGrid");
          var row = $(e.target).closest("tr");
          row.toggleClass("k-state-selected");
          var data = grid.dataItem(row);
        });
      }
});  
<!DOCTYPE html>
<html>
<head>
   <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.common-bootstrap.min.css" />
    <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.min.css" />
  <link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.914/styles/kendo.bootstrap.mobile.min.css" />
     <script src="http://ift.tt/ZnjyAz"></script>
    <script src="http://kendo.cdn.telerik.com/2016.3.914/js/kendo.all.min.js"></script>

    <script src="http://ift.tt/ZnjyAz"></script>
    <script src="http://ift.tt/2d5VZqi"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="grid"></div>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire