This is a migrated thread and some comments may be shown as answers.

Grid Change event fires 2 times

1 Answer 393 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 27 Nov 2013, 05:27 PM
When I set up a grid to selectable: "row" and capture the change event I see the change event fire twice here is a really simple grid to use as an example:
<html>
<head>
<script>
var data = [
    {"col_a": "vala1","col_b": "valb1","col_c": "valc1"},
    {"col_a": "vala2","col_b": "valb2","col_c": "valc2"},
    {"col_a": "vala3","col_b": "valb3","col_c": "valc3"},
    {"col_a": "vala4","col_b": "valb4","col_c": "valc4"}
           ];
        $(document).ready(function () {
            if(typeof(data) != "undefined")
            {
                $("#grid1").kendoGrid({
                        dataSource: {data: data},
                        columns: [
                        {field: "col_a", title:"ColA"},
                        {field: "col_b", title:"ColB"},
                        {field: "col_c", title:"ColC"}
                        ],
                        sortable: true,
                        resizable: true,
                        width: "95%",
                        height: "400px",
                    selectable: "row",
                        change: function(e){                          
                                alert('change');
                                }
                });
            }
            else
            {
                $("#grid1").addClass("k-block");
                $("#grid1").text("No data.");
                $("#grid1").css("font-weight", "bold");
                $("#grid1").css("font-size", "14px");
                $("#grid1").width(400);
            }
        });
</script>
</head>
<body>
<div id="grid1" style = "width:99%;"></div>
</body>

its also in action here: http://jsfiddle.net/jnv9M/

Any way to prevent this or any help as to why I'm getting this event twice?

1 Answer, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 28 Nov 2013, 09:42 AM
Hello Brian,


Generally alerts are not a good way to test event firing. I would suggest you to switch to console.log instead. Here is a modified JS Bin example, which demonstrates that the event is fired once.

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Brian
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Share this question
or