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

Setting a range destroys formatting

2 Answers 72 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Adam Boddington
Top achievements
Rank 1
Adam Boddington asked on 16 Jan 2012, 04:50 AM
I've set up a datepicker like this...

    $(document).ready(function () {
        $("#timeshiftDatePicker").kendoDatePicker({
            max: "01/05/2012",
            min: "08/12/2011",
            value: "12/30/2011"
        });
    });

It displays the date correctly and limits the range correctly, but when I click on another date the value shown is something like "Tue Dec 27 2011 00:00:00 GMT+1000", not "12/27/2011". I originally thought it might have something to do with setting the culture to en-AU (I reversed my dates when that was set), but I've removed that and I still get the problem.

2 Answers, 1 is accepted

Sort by
0
Adam Boddington
Top achievements
Rank 1
answered on 16 Jan 2012, 05:39 AM
Setting a range also seems to prevent a change event from running. This works.

    $(document).ready(function () {
        $("#timeshiftDatePicker").kendoDatePicker({
            change: function() {
                alert("hmm");
            }
        });
    });

This doesn't.

    $(document).ready(function () {
        $("#timeshiftDatePicker").kendoDatePicker({
            max: "01/05/2012",
            min: "08/12/2011",
            change: function() {
                alert("hmm");
            }
        });
    });

The range is set correctly preventing me from choosing dates outside the bounds, which is great. But the alert box doesn't show and formatting is broken once a date is selected as per my previous post.
0
Adam Boddington
Top achievements
Rank 1
answered on 16 Jan 2012, 05:51 AM
Whoops, sorry, my bad. I'm doing it wrong. The date range should be set with Date values not strings.

    $(document).ready(function () {
        $("#timeshiftDatePicker").kendoDatePicker({
            format: "dd MMMM yyyy",
            max: new Date(2012, 0, 5),
            min: new Date(2011, 7, 12),
            value: new Date(2011, 11, 30),
            change: function() {
                alert("hmm");
            }
        });
    });

Everything is working wonderfully again.
Tags
Date/Time Pickers
Asked by
Adam Boddington
Top achievements
Rank 1
Answers by
Adam Boddington
Top achievements
Rank 1
Share this question
or