How to reset polymer iron-autogrow-textarea or paper-textarea through it's methods? - polymer

I am able to clear iron-autogrow-textarea by setting the value to empty string but I am unable to clear the newline or reset it. I am using event on keycode enter which works but leaves this new line and no way I can find a way to reset the iron-autogrow-textarea to its initial state.
If anything similar can be done with paper-textarea, I can use that instead.
Any help appreciated.

Here below information is written in its own page, so you need to update with : ironAutogrowTextarea.value
Imperatively updating ironAutogrowTextarea.value will update the
textarea.value
instead ironAutogrowTextarea.textarea.value
Imperatively updating ironAutogrowTextarea.textarea.value will update
the display, but not update the internal value
Written its demo link: https://www.webcomponents.org/element/#polymer/iron-autogrow-textarea/demo/demo/index.html

Related

trigger itemSelect event on Primefaces autocomplete

I have a primefaces autocomplete element which works great except one thig. The problem is that when I enter a valid text (which is mappable to the data behind) but I don't select the element from the propositions, and don't press tab or enter, nothing happens.
So I enter a value and click into another field, the element is not selected and the validation fails. However, I don't want the user to force to explicitly select an item.
My ideas were, that i put an onchange listener to the input element and trigger the primefaces itemSelect event within. But I don't know how to do that, if it's even possible.
Or maybe there are other solutions?
Thanks in advance!
I found a way, although it might not be the most beautiful and easy one.
Maybe it helps somebody...
This is a specific solution for primefaces (5.3), but it should work for other versions too.
$('#form\\:txtAutoComplete_input').val('Foo');
$('#form\\:txtAutoComplete_input').trigger('keydown');
$('#form\\:txtAutoComplete_input').trigger('input');
$('#form\\:txtAutoComplete_panel .ui-autocomplete-item').trigger('click');
For some reason, after the value is entered into the input field, you have to trigger the keydown and the input event in that order. After these events the autocomplete list shows with the matching values. There you have to trigger click on a certain element, so all the backing bean stuff is properly executed.
There is an API for Primefaces widgets.
For instance ;
<p:autoComplete id="gtautoaomplet" value="#{item.soemprop}" completeMethod="#{bean_CrossCheckNew.completeText}" scrollHeight="250"/>
In JS code ;
widget_form_mapingGrid_0_gtautoaomplet.search('foo');
When you write "PrimeFaces.widgets" in your browser console you can see all the widgets available in your page.
For more datail :
https://primefaces.github.io/primefaces/jsdocs/index.html
Good luck.

Access Violation Exception on Textbox Autocomplete

In textchanged event Access Violation Exception occurs frequently.
it's a security level problem may be. try this: Go to the Project Property page, and then go into the Security Section.
"Enable ClickOnce Security Settings" will be seen checked. uncheck it
reference: https://social.msdn.microsoft.com/Forums/windows/en-US/e599b2e2-3cda-43ad-b15f-a69b4fea1a75/dynamic-filling-of-textbox-autocomplete-not-working?forum=winforms
I too wanted to populate a TextBox AutoCompleteCustomSource using the users input from that same textbox as a filter, so I had the TextChanged event grabbing data to fill the dropdown suggestions list.
I tried so many different ways to fill the data, which all resulted in random or constant Access Violation. If I'm not wrong I finally have it nailed down I think.
It seems that it doesn't matter what method you're using to actually add the items to the AutoCompleteCustomSource. The problem arises when you go to replace those items.
Before changing any of the data in TheTextbox.AutoCompleteCustomSource, you need to first set:
TheTextBox.AutoCompleteSource = AutoCompleteSource.None
Then you can use any method you like to clear and/or refill it:
TheTextBox.AutoCompleteCustomSource.Clear()
TheTextBox.AutoCompleteCustomSource.AddRange(AutoSuggestItems)
Set the AutoCompleteSource back to CustomSource when you're done:
TheTextBox.AutoCompleteSource = AutoCompleteSource.CustomSource
' prevent that annoying selection of the whole textbox text
TheTextBox.Select(Me.TheTextBox.Text.Length, 0)
*Note: If you also set TheTextBox.AutoCompleteMode while changing the data like I was originally, it causes the Access Violation error later. (SO FAR) the above method has worked correctly. I hope this is my last update to this solution :)

how to disable bootstrap-dateTimepicker's pick function?

now, I am trying to disable the pick function for some reason, I just want to display the date/time, but it can't be done, it seems that there is no such option or function to reach this? Anyone has an idea why this is the case?
I find that in the latest version of datetimepicker, there is a option "ignoreReadonly", it's default value is false and we don't change it. Just to make add the readonly attribute to the input. Then we can disable the widget.
In my old version, there is no such option. so, thanks for your answers and thanks Eonasdan. by the way, the version contains this option, is 4.14+.
And you can view the demo by [disabled datetimepicker demo](https://jsfiddle.net/xjkms/hzwpsnjw/2/).

Multiselect select element - capturing current option set before adding / removing new items

Hello and thank you for reading.
I have an aspx form hosted in SharePoint 2010 that has some multiple select elements within a form. There are buttons to add and remove options from these select elements.
My problem is that I need to run a query based on the options within these multi select elements each time new options are added / removed from them. SharePoint is executing some server side code I don't have access to but here's my underlying problem.
If I hook into the buttons' onclick event, when my function is called the options have already been added to or removed from the select element. I need to capture the current option set of these elements, before the onclick function executes.
Is there another event I can tie into? Something like onbeforeclick on the buttons or optionsChanged on the multi select element? It doesn't look like any event will satisfy what I need to do here, but I'm hoping someone has faced a similar issue before.
Thanks,
Zachary Carter
The only solution I could come up with is to capture the present set of options each time an option is added or removed.
This solution is going to involve alot of array manipulation however, and if I can avoid that and simply tie into an event, before the onclick event of the button is called, that would be my ideal solution.
This might not be a great answer to your question, and if not, I apologize. However, I just ran into a very similar problem, albeit using Visual Basic. The solution wasn't elegant in my eyes, but I used VB's MouseUp event, which fires when the mouse button is released. On release (i.e., at the end of the previous action), I save all the information in the elements into an array, and then on the next click, before anything else happens, I can check against that array.
Edit: Gah, looks like you posted essentially that solution while I was typing. Sorry I didn't notice.

VBA Form update after values set in code instead of AfterUpdate()

I have multiple combo and option boxes whose visibility is set true or false depending on user selection of other parent option boxes.
I am using the AfterUpdate() function for the parent option boxes. This method has been working fine.
However when I set the values of the option boxes in VBA code (Me.MyOptionBox = 1), there is no "update" to make the child option and combo boxes appear. It works when I manually click on the option, but if I set it in the code nothing changes except for the option box selection. It doesn't make sense to see the option box set correctly but the code responsible for checking which option is selected not work.
Does anyone have any ideas on how to get around this? I just want the form to be updated once I set the values of the option boxes. What is the "update" that AfterUpdate() is referring to anyway?
I have tried MyForm.Repaint and MyForm.Requery but these do not work either.
Any ideas?
You can call the OptionBox_AfterUpdate() method directly - after you set the values.
I'm pretty sure this is intentional. The problem is avoiding circular recursive updates, when you consider that a control can be changed by a user and by two forms of code (explicit and bound data).
For bound controls, changes in the data change the controls.
For user input, changes in the control change the data, plus whatever dependendencies you explicitly specify in events.
For changes caused by your code, the assumption is that you need to manually apply all the consequences of the state change you are coding.
If you are using bound controls, you can change the datasource and have the consequences applied automatically.
In VBA, most control events do not fire when the control is updated programmatically, rather than manually. You must specify the code that is to run after the programmatic update.
By "I am using the AfterUpdate() function," you mean you added an event handler for the AfterUpdate event, right?
If that handler is not firing when you expect it to, you could always call your handler directly (instead of letting the event fire it) where necessary. But that probably wouldn't be the best way of doing it; more likely there is another event that should be calling your handler instead of or in addition to AfterUpdate. I don't remember the names of combo box events, but isn't there something like ItemChanged or SelectionChanged or something?