I have a native Date Picker in a windows phone app.
Using the DateChanged event I can perform actions when the user submits.
DatePicker.DateChanged += (o, args) =>
{
var date = args.NewDate;
// Do something with it
}
The problem I am facing is the event is not triggered if the user submits the date picker without changing the date.
Default value is set to today's date which makes it impossible to select this date.
Does anyone know how I can allow the user the select this date and perform actions after ?
Thanks for your help :)
There is no particular way of getting an event fired when the date is not changed. As you said the date picker by default selects the current date, you can perform the action you want to if the user selects today's date in the OnNavigatedTo, Loaded, or DatePicker_Loaded event. A better way to do so is providing the DatePicker an invalid date something like 1Jan1947, this ways the user has to change the date else it'll be invalid. Also if you write the code you want on dateChanged event, it'll fire automatically as when the DatePicker is Loaded it sets the date from default to the current date.
What I would recommend
is to use a binding property to hold a value and then performing the
operations onPropertyChanged event of that property. This ways your
logic is independent of your datePicker and you could write events
for each time the dateTime property changes.
Do remember to bind the datePicker's date property to the DateTime
property in a TwoWay Mode and an UpdateSourceTrigger of
PropertyChanged. This ways when you change the property from code
behind the data would reflect in the datePicker and when you change
the value in the datePicker, the data would be reflected in the code
behind as well
Related
We're using the date input component as part of some parameterization on a page. So, as soon as the onChange event fires we want to go fetch some more data.
The problem is that the onChange fires too often as a user is typing. If I type just "Nov" that's setting a valid date of Nov-01-YYYY, and so the onChange event fires. I believe I would like to fire the onChange only when a full date has been entered, or the enter key is pressed, though I'm open to other ideas.
DateInput does not currently provide such a feature. Sounds like you're requesting an onConfirm handler. GitHub is the place to request features.
I have a form which is using DateTimePicker on one of the inputs. I would like the user to be able to select the date/time by using the buttons which KendoUI attaches to the right of the input field, however I don't want the user to free-type into the text field (to save me having to verify formatting or rubbish input).
It is possible to add readonly attribute to the input, either in HTML or by calling .readonly() method on the DateTimePicker object. This makes the text field un-editable, however it also prevents the click events on the date/time selectors from firing.
So, how do I prevent the user from being able to edit the textbox field manually?
Thanks in advance.
Yes, you can set the readonly attribute only of the input from which the datepicker was created:
<input id="datepicker">
<script>
$("#datepicker").kendoDatePicker().attr("readonly", true);
</script>
Here is a live demo: http://jsbin.com/uwayit/1/edit
I'm facing a problem that I can't understand. I'm using Kendo Grid with InCell edit and I have a DateTime field in my Model.
When the grid enters in edit mode, the calendar is shown, but the grid only saves the inputed value if I select the value from the calendar. If I input the field manually, the value is not saved and the cell is not marked has dirty.
If it helps, I'm using MVC with Razor sintax.
Tks in advance!
I've found a workaround in Kendo's forums:
By design, the DatePicker does not raise the change event when the value is set programmatically - it raises only if the date is modified by the end-user. In case you need to trigger the change event, you can use jQuery trigger().
For example:
var datePicker = $("#datepicker").data("kendoDatePicker");
datePicker.value("01/01/2001");
datePicker.trigger("change");
Reference:
http://www.kendoui.com/forums/ui/date-time-pickers/datepicker-change-event.aspx
So basically what I did was to force the change event manually.
How to render an existing jquery datePicker based upon new values upon ajax post? And how do I change the start date of display based upon a particular date in the ajax post
Fire a function, that generates the date picker, when the ajax response is ready.
jQuery date picker has option defaultDate, which You can also change, when rendering new version of date picker.
I am using the DatePicker control from WP7 control toolkit in my app for the user to enter in an expiration date. One of the scenarios is that the record doesn't have an expiration date. How can I use the control such that by default, there is no date specified in the control and the user can select a different date?
Also, if I user sets an expiration date but letter wants to clear it, I need to enable that as well.
Pratik
For the default value to be blank, in the XAML
<toolkit:DatePicker x:Name="dpComp" Value="" Width="220" Hold="dpComp_Hold"/>
If you would like to allow a user to clear the value of datepicker then you can do this in the code
private void dpComp_Hold(object sender, System.Windows.Input.GestureEventArgs e)
{
//Let user to clear the value.
((DatePicker)sender).Value = null;
The DatePicker control doesn't support the concept of no date selected.
The DatePicker will default to the current date if none is selected on the assumption that this will be the most useful to the user. Forcing the user to select values which you could provide a likely default value for means you're making the user do more work than they should have to and you are therefore wasting their time.
If no expiry date is valid, leave this field blank by default.
With regard to clearing an entered date, add a separate option to do this. Either a button or menu option.
I would look at the .api for customization of the DatePicker Control: http://windowsphonegeek.com/articles/wp7-datepicker-and-timepicker-in-depth--api-and-customization
I don't know of anyway to do what you are looking for (however I might want to know in the future). The link above seems to suggest you can create your own custom page and you can then maybe work out a way to return what you are looking for.