How to Date field of datepicker non editable - datepicker

For Xamarin.Forms.DatePicker, the date field is "tappable" , the user can change the date after selecting it in the date picker. How to make the data field non-editable(read-only)?

You have to set IsEnabled=false
<DatePicker IsEnabled="false"/>
IsEnabled is the property of VisualElement from which all controls are inherited.
It Gets or sets a value indicating whether this element is enabled in the user interface. This is a bindable property.
public Boolean IsEnabled { get; set; }
true if the element is enabled; otherwise, false. The default value is
true.
If false, Elements are not enabled to participate in hit detection, and therefore will not receive focus or emit input events.

Issue is resolved when i added Control.ShouldChangeCharacters += (field, range, replacementString) => false; to custom renderer file

Related

how to set selected value in sap.m.searchfield ui5

I have used a sap.m.SearchField in(SAPUI5),
Now I want to set one of the suggestion item as selected, I mean I want to set a default value to the search field.
How to set selected value in sap.m.SearchField?
While defining SearchField itself you can set the value.
var oSearchField = new sap.m.SearchField({
value: "samplePreText"
});
If you plan to change on some event:
oSearchField.setValue("samplePreText");

System.Windows.Forms.ListView Check box is not recognized by UIA verrify

I am quite new to UI Automation and UI Verify tool.
In our application, we are using System.Windows.Forms.ListView with CheckBoxes property set to true.
The CheckBoxes property allows you to display a check box next to each item in the list. This enables your application to display a list of items (and subitems if the View property is set to View.Details)
So far individual row and all values in each row is identified. Only checkbox is not recognized by UI verify.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent()
listView1.CheckBoxes = true;
listView1.View = View.Details;
listView1.Columns.Add("Automation");
listView1.Columns.Add("result");
listView1.Items.Add(new ListViewItem(new string[] { "1", "Pass" }));
}
}
Output: Both values "1" and "pass" are recognized by UIA verify. However the check box is not recognized.
Has anybody else experience similar behavior? and if so is there any fix for this?
Much appreciated for all the help.
Regards
Hari Hara
From what I can see the whole list item supports the toggle pattern.
So you should be able to use the toggle pattern of the row control itself.
/// <summary>
/// Toggles anything that supports the toggle pattern
/// </summary>
/// <param name="aeElement">Automation element to toggle</param>
public void Toggle(AutomationElement aeElement)
{
TogglePattern tpToggle = (TogglePattern)aeElement.GetCurrentPattern(TogglePattern.Pattern);
tpToggle.Toggle();
}
Are you using "hover" mode? Try checking the pane structure near the checkbox items in the left pane of UIA verifier window.

How to disallow focus at a readOnly field

We have a form with few fields marked as readOnly.
The issue is that the user is able to focus or navigate to these readOnly fields using mouse or keyboard tab, and we want to disallow this.
One way of not allowing this is to mark all such fields as 'disabled'. But when marked disabled, then though fields can not be focussed, but then these disabled fields also do not get submitted to the server which is not what is expected.
Thus, how can we prevent a focus at readOnly fields?
PS: The reason behind disallowing focus at readOnly fields is to provide better navigation through keyboards, so that by using tab key user navigates or jumps across only those fields which he can edit and all readOnly fields get ignored.
You could add a listeners to the base Field class that listens for focus events then if the field is readOnly to focus the next component.
listeners: {
focus: function(field)
{
if (field.readOnly)
{
field.nextSibling().focus();
}
}
}
Just override getSubmitData method and assign some other property to let overridden method know you want to submit regardless (say, forceSubmit):
Ext.define('My.form.Field', {
override: 'Ext.form.field.Field',
getSubmitData: function() {
var me = this,
data = null;
if ( me.disabled && me.readOnly && me.forceSubmit ) {
data = {};
data[me.getName()] = '' + me.getValue();
}
else {
return me.callParent();
}
return data;
}
});
Then you can require this class in your code and set the fields you need to be disabled, readOnly and have forceSubmit:
my field = new Ext.form.field.Text({
disabled: true,
readOnly: true,
forceSubmit: true,
value: 'foo'
});
That should do the trick.

Seam/RichFaces: Rendering based on result of a JavaScript function or variable

I have a RichFaces component that I want to render after an Ajax call which sets a JavaScript variable to either true or false.
When the variable is false, I don't want the panel to render. Is there any way to input the result of this variable (or any JS function call) in the rendered attribute of a component?
Richfaces renders components on the server side. So you have to pass your
parameter to server side. There are some ways to achieve this.
Create a hidden input on the page and link it to a flag in your bean. Something like,
class YourBean {
private boolean visible = false;
//getter,setter
}
On the page,
<h:selectBooleanCheckbox id="hiddeninput" style="visibility:hidden"
value="#{yourBean.visible}"/>
<rich:component id="compid" rendered="#{yourBean.visible}" />
<a:commandButton onclick="document.getElementById('hiddeninput').checked=true"
reRender="compid"/>
Or create two methods which sets flag to true or false.
class YourBean {
private boolean visible = false;
public void makeInvisible() {
visible = false;
}
public void makeVisible() {
visible = true;
}
}
On the page,
<rich:component id="compid" rendered="#{yourBean.visible}" />
<a:commandButton action="#{yourBean.makeInvisible()}" reRender="compid"/>
Option 1:
You can show/hide using JavaScript/jQuery from oncomplete attribute on ajax request.
Option 2 (better): you change a boolean property value in backend action's method, and use its value in rendered attribute.
RichFaces reRender can take an EL expression:
reRender="#{bean.componentsToUpdate}"
So, another option, you can decide in runtime (based on input) whether to render a particular component.

how to make dropdown in asp.net mvc as readonly?

How can i make drop down as read only in the asp.net MVC Pattern version 2 after it filles?
You could use jquery to disable all options in the dropdown.
$("#DropdownID option").attr("disabled","true");
This will show the options, but they are not selectable..
This doesn't work, a disabled dropdownlist does not post it's selected value on a form post, if a model property is bound to the dropdownlist the model's property value will be submitted as a null value.
This is an old post, but... my preferred method is to disable the options, not the control, so that it posts the selected value back.
public static MvcHtmlString SecureDropDownListFor<TModel, TProperty>(
this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
IEnumerable<SelectListItem> selectList,
string optionLabel,
object htmlAttributes,
bool alwaysReadonly)
{
bool isReadonly = !CurrentUserCanEdit(expression) || alwaysReadonly;
var attributes = new RouteValueDictionary(htmlAttributes);
if (isReadonly)
{
// This will pick up the style but not prevent a different option from being selected.
attributes.Add("readonly", "readonly");
}
var retval = htmlHelper.DropDownListFor(expression, selectList, optionLabel, attributes);
// Disable all but the selected option in the list; this will allow user to see other options, but not select one
if (isReadonly)
{
retval = new MvcHtmlString(retval.ToHtmlString().Replace("option value=", "option disabled=\"disabled\" value="));
}
return retval;
}
The effect of this is that the user can click the down arrow and see the unselected options, but can't select any of them. Since the select itself is not disabled, only the options, the selected value will be included in the postback.
The following is a solution that can prevent users from making any selection on the dropdownlist and still submit the value of the selected option in a form post.
A dropdownlist marked as readonly.
#Html.DropDownListFor(model => Model.SomeID, new SelectList(ListOfOptions, "Value", "Text", Model.SomeID), new {#class = "disabled", #readonly = "readonly"})
or simply
<select class="disabled" readonly="readonly">...[All your options, one of them selected]...</select>
And then a jquery that will disable the options that are not selected (that is the key).
$('select.disabled option:not(:selected)').attr("disabled", "true");