Assuming the DateRangePicker as a date range set already like this by the model
@(Html.Kendo().DateRangePicker()
.Name("daterangepicker")
.Min(DateTime.UtcNow.AddYears(-25))
.Max(DateTime.UtcNow.AddYears(25))
.HtmlAttributes(new { style = "width: 100%", title = "Event's Date" })
.Range(r => r.Start(Model.StartDate).End(Model.EndDate))
.Events(e => e.Change("onChange"))
)
@Html.HiddenFor(model => model.StartDate
@Html.HiddenFor(model => model.EndDate)
<script>
function onChange() {
var range = this.range();
if (range.start && range.end) {
$("#StartDate").val(kendo.toString(range.start, 'd'));
$("#EndDate").val(kendo.toString(range.end, 'd'));
//$("#StartDate").val(range.start);
//$("#EndDate").val(range.end);
$("#StartDate").trigger("change");
$("#EndDate").trigger("change");
}
}
</script>
When opening the dataview to change the selection (range) it should open at the set range instead of today's date which might be years apart. We shouldn't have to create a script which BTW is not opening the dataview_current on theproper date either.
$(document).ready(function () {