How to set highlighted-day in react-day-picker - react-day-picker

I am using react-day-picker. By default, it shows system date as the highlighted date. I want to use the date received from the server and make it highlighted date.
Here's my code :-
<DayPickerInput
onDayChange={this.handleDayChange.bind(this, 'maximumDeliveryDate')}
format="DD/MM/YYYY"
formatDate={formatDate}
placeholder="DD/MM/YYYY"
value={this.state.maximumDeliveryDate}
inputProps={{readOnly: 'readOnly'}}
dayPickerProps={{
selectedDays: this.state.selectedDay,
disabledDays: {before: new Date()}
}}/>
Has anyone done something like this?

Related

Karate - input field/textarea clear field is not working properly

Using Karate I am not able to clear field (input, textarea) properly:
<input name="title" id="title" class="form-control" placeholder="e.g. My MacBook Key" value="">
1) insert to input field with id=title is OK.
retry().input('#title', 'something')
Everything is written to field. OK.
2) I need to clear the field. I use following:
retry().clear('#title')
Field seems to be deleted after this action (text in input field is not visible).
3) But when I use input again
retry().input('#title', 'new')
In field is displayed: somethingnew. It seems that first string was not properly deleted and strings are merged together.
It happens for input/text area fields.
Could you help me please? Any idea?
Thank you.
Try using value() or JS directly instead of clear():
* value('#title', '')
Or:
* script('#title', "_.value = ''")
First we need to focus on the web element
focus(webElement)
Then clear the input field/text area on the browser, use clear()
clear(webElement)
To clear the value from DOM, we are using Key.CLEAR
input(webElement, Key.CLEAR)
Finally insert your value/custom value into the input field as below
input(webElement, "Insert your value")

SAPUI5 DataBinding for sap.m.DatePicker

How can I bind a DataSet to sap.m.DatePicker?
I would like to show a default Date in my DatePicker. The value is coming from a backend oDataService.
I am familiar with binding DataSets to ComboBox items etc, but on Input Fields or a Date Picker this is not working.
I also tried to attach a dataReceived event in the onInit function, but this event is never called.
Does anybody have a working example for me?
Here my exemple:
In the view.xml
<DatePicker id="startDateEvent" displayFormat="short"/>
In the controller.js :
var startDate = this.byId("startDateEvent");
startDate.setDateValue(<data date from backend>);
You need to be very careful with the Date and DateTime types. The snippet below works with the dateTime variables in Northwind like this one for example
<DatePicker value="{path:'yourPathToTheODataProperty', type: 'sap.ui.model.type.Date', formatOptions: { style: 'full'}}"></DatePicker>
You can change the format options for a predefined one as explained here or set your own LDML pattern, as described here

TextBoxFor producing a blank field

I have a weird problem in my MVC app.
When the user selects a date from a drop down, it clears the StartDate and EndDate fields.
I have the following fragment of code:
<label>Start date: #Model.StartDate</label>
#Html.TextBoxFor(s => s.StartDate)
The weird thing is that you can wee where I'm outputting it in the label, the date comes out there. The textbox is unpopulated.
I've checked the produced markup and the textbox is not being populated.
<label>Start date: 19/05/2013</label>
<input id="StartDate" name="StartDate" type="text" value="" /> <br />
What am I missing here?
To add a little bit more information, when the page is initially populated the default start and end date are output. There is a bit of jQuery that empties those fields when a <select> is changed. If I comment that bit out then the fields retain their previous values as opposed to blank. Essentially, whatever is submitted to the server is output rather than the value in the model.
Essentially, whatever is submitted to the server is output rather than the value in the model.
This behaviour is actually by design. The idea being that generally the user would expect to see in the text box what they submitted to the server.
See here for a detailed explanation, and a work around.
Instead of doing this
<label>Start date: #Model.StartDate</label>
#Html.TextBoxFor(s => s.StartDate)
You should do this
<label id="someId"></label>
#Html.TextBoxFor(s => s.StartDate,new{#id="startdate"})
and using jquery on change event on your textbox you can set lablel
$("#startdate").change(function(){
var date="Start Date:"+$(this).val();
$("#someid").html(date);
});
Thinks that your model is a class named What like this:
public class What
{
public string StartDate { get; set; }
}
Then, think that your application is "MyApplication", you need to add to the view as if the view is stronglytyped:
#using MyApplication.Models;
#inherits System.Web.Mvc.WebViewPage<What>
Then all should we run as you expect

Range validation

Suppose I have a table like:
create table
{
id numeric(5,3),
code varchar(10)
}
I have two text boxes in my form for the two fields.
Suppose if I type 1234578 in the first text box the error has been thrown in ASP.NET because I crossed the limit.
How can I validate in JavaScript or some other way for that particular range validation?
Let's take one textbox only. Attach an 'onchange' event handler to your textbox like this:
<input type="text" onchange="handleChange(this);" />
Then declare a script for validation like this:
<script>
function handleChange(input) {
if (input.value > ..your_value_here..) alert ("Invalid input");
}
</script>
Please note that the alert pop-up used here should not be actually used. Use a more subtle reminder at a more appropriate moment. The alert here is only to make things simple.

How to validate a <mx:List component>?

How can I validate if atleast one item has been selected from a list, such that the selectedIndices is set to NULL at the init() of application?
Following code can be of help to someone who want to validate a list like I wanted:
<mx:NumberValidator
id ="myListValidator"
trigger ="{myButton}"
triggerEvent ="click"
minValue ="0"
lowerThanMinError="Should I write an application to you for selecting atleast one of the option X-("
source ="{myList}"
property ="selectedIndex"
/>

Resources