How to clear a DatePicker - javafx

I have a DatePicker for selecting birthday.
This is going to be used for some filtering, and after the filtering, I will like the value to be reseted, i.e. the DatePicker should go blank.
Any help???

If you want to clear the TextField of the DatePicker, you can use :
datepicker.getEditor().clear();
If you want to clear the value and the textfield, use :
datePicker.setValue(null);

if you want to set the the value of a datepicker to its default value or the current date you can use this
datepicker.setValue(LocalDate.now());
or if you want to clear the textfield of the datepicker`
datepicker.getEditor().clear();

just add this code
}).keyup(function(e) {
if(e.keyCode == 8 || e.keyCode == 46) {
$.datepicker._clearDate(this);
}
});
You can use backspace to clear field even if it has in read only mode.
Source

Related

w2ui grid inline edit enter-key behaviour

when inline-editing a text column in the w2ui.grid the ENTER key applies the change AND starts editing one row below.
How can I prevent the editing of the line below, but only apply the changes to the current row?
Thank you.
You can do this by cancelling the edit event if the previous keycode was ENTER.
w2ui.grid.onEditField = function(event){
if(event.originalEvent.keyCode === 13){
event.preventDefault();
}
};
fiddle: http://jsfiddle.net/ty77umx1/1/

Save changes in editable data grid with enter key - xpages

I have a data grid that displays on my xPage. I allow the user to edit two of the fields in the grid. I would like either field to recognize the user hitting the enter key and automatically save those line changes to its document. I don't want to use a button for the user to manually click. Can someone explain how I can do that with a code snippet? Thanks.
Mike
Mike,
In your edit fields, you can have code like this. Note that keyCode #13 is the enter key. You can find out the keycode of specific keyboard keys using http://keycode.info/
You would likely want to execute serverside code to save your document. I haven't every tried using the keycode in SSJS, so I can't say it works for sure. But the keypress event is the way to go for what you are trying to accomplish.
var keyCode = event.keyCode;
if(keyCode == 13){
//Save here
}else{
event.returnValue = false;
}
If the UI doesn't make it easy to add the keypress event, you can still add it to the source. It has to be on an editable input field to work.
<xp:eventHandler event="onkeypress" submit="true" id="eventHandler1" refreshMode="partial">
<xp:this.action><![CDATA[#{javascript:var keyCode = event.keyCode;
if(keyCode == 13){
//Save here
}else{
event.returnValue = false;
}}]]></xp:this.action>
</xp:eventHandler>

Validation for Kendo AutoComplete when user does not select the value

I want the validation for kendo AutoComplete when user does not select any value from AutoComplete Value that is populated.
For Little Bit background say I do have two controls one as Kendo AutoComplete and other is Input box if user types something in the AutoComplete the values is populated and he does not select any value and switch to next control it must give a validation message that please select the value from the AutoComplete.
and Also if the user type any string in the AutoComplete and Switch to next control it must also give the validation that "hey,this value is not in the AutoComplete" so that it must not save any other data other than AutoComplete datas that is being Populated.
Heres how your auto complete is defined
#(Html.Kendo().AutoComplete()
.Name("countries")
// etc.
On submit button click event
<script>
$("#btnSubmit").click(function(){
var autoCompleteValue = $("#countries").val();
if (autoCompleteValue == "" || autoCompleteValue == null){
return false; //cancels submit action
}
// else let submit go through
});
</script>
The null check is probably useless, cuz if it doesn't have a value it's usually equal to ""
The .val() solution did not work for me, because the .val() value of the control is still the text I entered (custom text, not any of the AutoComplete values), and that's wrong.
Solution is in preventing the custom input of Kendo AutoComplete. See this link:
Kendo UI - Prevent Custom User Input in the AutoComplete

In Flex, how do I create a CheckBox that can't be un-checked?

In Flex, how do I create a CheckBox that can't be un-checked? I run a function when the checkbox is clicked. If that function encounters an error, I want the state of the checkbox to remain the same. How do I do that?
You can use the enabled attribute to prevent the checkbox from being accessed once it's in the state you mentioned.
onFunctionError():void {
yourCheckbox.enabled = false;
}

How can I get value from radio-button inserted into innerHtml

I have sort of a table with a radio-button column. I managed to make radio-button column work dynamically inserting into a cell (div if matter). But, on postback innerHtml hasn't been updated with "checked" attribute.
Could you give me an idea how can I find out (on the server) if radio-button has been checked?
More info: This is on user control inside update panel.
This would be good post on my topic, still doesn't help
Any reason you cannot use a standard asp:RadioButton and use javascript to ensure it is mutually exclusive. I have done this before by adding a custom attribute to the radiobutton and then using a js function to uncheck all items with that attribute and then check the selected one. This works around the IE issue which prevents the groupname attribute from working on radioboxes that are in different containers.
radioButton.InputAttributes.Add("ClientGroupName", "grpRadioList");
radioButton.InputAttributes.Add("onclick",
string.Format(
"javascript:radiobuttonToggle('{0}','ClientGroupName','grpRadioList');"
,radioButton.ClientID));
and use the following JS to uncheck all radios and then check the one you want.
Note i used InputAttributes instead of Attributes as the radiobutton is wrapped inside a span tag so InputAttributes is for items added to the actual input control rather than the span.
function radiobuttonToggle(selectedRB, attribName, attribValue)
{
var objRadio = document.getElementById(selectedRB);
for(i = 0; i < document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i];
if (elm.type == 'radio')
{
if(elm.getAttribute(attribName) == attribValue)
elm.checked = false;
}
}
objRadio.checked = true;
}
You can then expose radioButton.Checked as a property in your CS file and reuse this as a control.
Check Form.Request("radio-name") != null
You only get a non-null value when it's been checked.
Make sure your page elements are being rebuilt correctly on postback. Any binding process that inserted the radio buttons the first time around will have to be re-run before you can access them the second time.
Here is a working example, first I add radios to my webform by the method you linked :
function addRadio()
{
try{
rdo = document.createElement('<input type="radio" name="fldID" />');
}catch(err){
rdo = document.createElement('input');
}
rdo.setAttribute('type','radio');
rdo.setAttribute('name','fldID');
document.getElementById('container').appendChild(rdo);
}
Then at code behind I used only the code below to get the radio's value :
string value = Request["fldID"];
So, be sure you're trying to get the name of the radio buttons at server side. You should use name attribute at server side, not id.

Resources