Extjs suspendEvent on radio button - extjs

I am using Extjs4.2.2.
For a radiogroup I have a change listener in controller. I am changing radio selection several times progmatically but I don't want change events to fire in some cases. So I used suspendEvents before changing the selection as follows:
radio.suspendEvents();
//radio.suspendEvent('change');
radio.setValue({communication: 1}); // where communications is the name of radios
However this did not help and a change event is still fired.
How to stop that.

The suspendEvent event bug is there for comboboxes too. Here are the bug reports:
http://www.sencha.com/forum/showthread.php?171525-suspendEvents-did-not-affect-to-Ext.app.Controller.control
http://www.sencha.com/forum/showthread.php?232919-ComboBox-suspendEvents-doesn-t-work
I found a solution that fixes it for comboboxes. Maybe the solution works for radios too. It works in Ext JS 4.2.1. Maybe other versions too.
radio.suspendCheckChange++;
radio.setValue({communication: 1});
radio.suspendCheckChange--;

Related

FocusListener on Tabs/ScaleImageLabel

I've added ScaleImageLabel to swipe Tabs. I want to calculate amount of time each tab remains in focus. I added focus listener to Tabs/ScaleImageLabel but it's not getting fired. It's working when added to the form. Any suggestions on how to achieve it?
If I understand correctly what you need is a tab selection listener. Focus listener will only work for focusable components and labels are by default non-focusable. I would recommend avoiding it since focus is used for key based navigation. It might produce different results than you would expect.

Angular Bootstrap: How to show a popover based on a child elements' trigger?

Demo Fiddle
I'd like to show some help text using a popover for the entire group of fields, not for each individual input.
In the fiddle, I'm simply using a mouseenter trigger to show how it should look like, but what I really want is to trigger it on focus for any input, but have the popover be positioned based on the parent element.
In non-angular land, I'd trigger a custom event (say groupenter) when any one of the fields is in focus, and have the popover listen to that event. I'd also debounce the corresponding groupleave event so the popover won't flicker as I tab around the inputs.
What's an angular-y way to accomplish that here?
(I think this patch helps, but it just got committed days ago)
Got it working!
I had to fork tooltip.js to add 'groupenter': 'groupleave' to triggerMap since there's no public api to add to the map.

How to implement listeners for selectionModel within controller in ExtJS 4.1 MVC

I have a grid with checkboxmodel selection model applied. Is there a way to put listeners on it within controllers control() method?
As far as DOCS say refs property is used to reference to Components only. SelectionModel is not a Component.
Simply register your listeners to the grid that contains this model using the supplied control() method of your controller. As far as I know all events from the checkboxmodel are bubbled up to grid. At least the selectionchange event works cause I use this one by myself along with a checkbox model.
'grid': {select: this.onSelect, selectionchange: this.onSelectionChange}
I don't recommend to use refs at all for such a case.
Edit:
As you might see in the API the checkboxes checkboxmodel are not of the type Ext.form.field.Checkbox. For that reason there is not single event from the checkbox that you may have in mind.
To force a selection by using the checkbox use
checkOnly: true
this will force a selection only by clicking the combo

Ext.button click() method

ExtJS 4.1.
Is there something like Ext.button.click(); method on Ext.button class?
Is it possible to programmically "click" a button with one method?
Or if you have an MVC structure you can fire the click event of the button, and if you're listening to the event in your controller and have an associated function it will get called.
button.fireEvent('click', button);
The last answer on this forum might give you more insight on how you can do that
here they are-
1)Create the event code in a function and call the function from both sides: btn.on("clic", ...) and from the code you want to simulate the click.
2)Use: btnView.btnEl.dom.click();
from -
http://www.sencha.com/forum/showthread.php?37772-Solved-Programmatically-click-an-Ext.Button
ExtJS 4.2.1
Ext.get('component-id-of-extjs-button').el.dom.click();
Ext.get('toggle-button2').el.dom.click();
works for me.
In case of buttons using handler, you can directly call the function of button.
Considering button is an Ext JS component, you can use:
button.handler(button);
or if you want to reach a function of event 'click':
button.listeners.click(button);
That would also work to call different button events.
Since I needed it for many buttons, it was easier to implement an override on the button class, which adds a click function:
Ext.define('Ext.override.Button',{
override:'Ext.button.Button',
click:function() {
this.getEl().dom.click();
}
})
After this override has been added to the code base, the following works like a charm:
Ext.getCmp("MyButton").click()
Unlike fireEvent or fireHandler, this will work with all kinds of buttons - no matter whether they have a click event or a handler, or whether they are toggle buttons where the clicked button has to be marked as pressed also.
If you need to execute the "handler" of the button, just run this (tested with ExtJS 4.2)
button.fireHandler()
If you want to do this in your test scripts, take a look at my Ext.ux.Test library. If you need it for something other, I would suggest reconsidering your approach.
None of the other answers worked for me, but i found something simplier i think :
var button=Ext.get('the_id_div');
button.dom.click();
document.getElementById("someButtonId").click();

ExtJS 3 Checkbox Click Listener

Right now I have change listener but it requires the checkbox to lose focus to register. I looked around online and was unable to find out if such listener (or better substitute) exists.
Is there anyway at all to create a click listener?
Have you tried check?
http://docs.sencha.com/ext-js/3-4/#!/api/Ext.form.Checkbox-event-check

Resources