jeudi 20 décembre 2018

Kendo UI - Javascript checkbox value submit to DataSource read

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 "getMarketData.php" able to get "c1" value (active) and reload in the same 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()">

My Javascript

<script>

$(function() {
    var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "/getMarketData.php",
                        type: "POST"
                    }
                },
                schema: {
                    model: {
                        id: "marketID"
                    }
                }
    });
});

function checkBox() {

    var checkbox = document.getElementById("c1");

    if (checkbox.checked == true) { 
        //pass "active" data
        $("#grid").data("kendoGrid").refresh();
        $("#grid").data("kendoGrid").dataSource.read();     
    } else {    
        if (checkBox.value == 'active') {
            var x = 'inactive';
        }
        //pass "inactive" data
        $("#grid").data("kendoGrid").refresh();
        $("#grid").data("kendoGrid").dataSource.read();
    }
}




Aucun commentaire:

Enregistrer un commentaire