Javascript checkbox submit to DataSource read

1 posts, 0 answers
  1. yazid
    yazid avatar
    1 posts
    Member since:
    Dec 2018

    Posted 20 Dec 2018 Link to this post

    I was newbie in Kendo Ui and also javascript programming. I have a simple question how to submit the value from my checkbox to dataSource transport : read?

    so "getData.php" able to get "c1" value (active) and reload the page again.

    Here I provide my code? Hope someone can help me. Thank You.

    My checkbox :

    <input type="checkbox" id="c1" name="checkbox1" class="k-checkbox" checked="checked"  value="active" onclick="checkBox()">

     

    Javascript code for checkbox:

    $(function() {
        var dataSource = new kendo.data.DataSource({
       transport: {
                  read: {
                           url: "/getData.php",
                   type: "POST"
                  }
                  },
                    schema: {
                        model: {
                            id: "segmentID"
                                  }
                  }
        });
    });
     
    function checkBox() {
         
        var checkbox = document.getElementById("c1");
         
        if (checkbox.checked == true) {

     

            $("#grid").data("kendoGrid").dataSource.read(checkBox.value);
        } else {
            if (checkBox.value == 'active') {
                var x = 'inactive';
            }
            $("#grid").data("kendoGrid").dataSource.read(x);
        }
         
    }
Back to Top