or
window.onbeforeunload = confirmLeavePage();function confirmLeavePage() { debugger; var dataSource = $("#ValuesGrid").data("kendoGrid").dataSource; var data = dataSource.data(); var hasChanges = dataSource.hasChanges(); for (var loop = 0; loop < data.length; loop++) { if (data[loop].dirty) { hasChanges = true; break; } } if (hasChanges) { return "You have made changes to the current values. The changes will be lost if you leave this page without clicking the save button"; }} <p> <label class="searchLabel" for="state">State:</label> @(Html.Kendo().DropDownList() .Name("state") .HtmlAttributes(new { style = "width:275px" }) .OptionLabel("Select state...") .DataTextField("StateName") .DataValueField("StateAbbr") .DataSource(source => source.Read(read => read.Action("GetStates", "Home"))) ) </p> <p> <label class="searchLabel" for="county">County:</label> @(Html.Kendo().DropDownList() .Name("county") .HtmlAttributes(new { style = "width:275px" }) .OptionLabel("Select county...") .DataTextField("CountyName") .DataValueField("CountyName") .DataSource(source => source.Read(read => read.Action("GetCounties", "Home").Data("filterCounties")) .ServerFiltering(true)) .Enable(false) .AutoBind(false) .CascadeFrom("state") ) </p> <p> <label class="searchLabel" for="city">City:</label> @(Html.Kendo().DropDownList() .Name("city") .HtmlAttributes(new { style = "width:275px" }) .OptionLabel("Select city...") .DataTextField("CityName") .DataValueField("CityName") .DataSource(source => source.Read(read => read.Action("GetCities", "Home").Data("filterCities")) .ServerFiltering(true)) .Enable(false) .AutoBind(false) .CascadeFrom("county") ) </p><script> function filterCounties() { return { state: $("#state").val() }; } function filterCities() { return { state: $("#state").val(), county: $("#county").val() }; } $(document).ready(function() { $("#state").data("kendoDropDownList"); $("#county").data("kendoDropDownList"); $("#city").data("kendoDropDownList"); });</script>$("#grouping").click(function () { $("#grid").data("kendoGrid").groupable(true); });
$("#removegrouping").click(function () { $("#grid").data("kendoGrid").groupable(false); });
$("#sorting").click(function () {
$("#grid").data("kendoGrid").sorting(true);
});

