I have two separate advancedDataGrid instances (let's call them A and B). What I'd like to do: when clicking on grid A I'd like
for grid A to handle the click normally (i.e. default advancedDataGrid behavior)
for grid B to receive a click event a certain location and handle such event using advancedDataGrid default behavior (i.e. without having to write a handler for such click).
Is this possible?
I've managed to dispatchEvent a MouseEvent.CLICK to grid B and to handle such event by creating an event listener, but really I'd like for grid B to handle the event on its own (i.e. without having to re-rewrite a handler), and that doesn't seem to be the case. Is MouseEvent.CLICK even the right event?
any help, pointers, advice would be immensely appreciated.
thank you!
There is no way to execute code after an event is dispatched without using an event listener.
I'm unclear exactly what you're trying to do, but there is no reason why you can't dispatch an event on an object that is not it's own. Instead of doing:
myContainerWithAAndB.dispatchEvent(MouseEvent.CLICK);
You can do this:
gridB.dispatchEvent(MouseEvent.CLICK);
And if there is a default handler in the gridB class to handle such an event, that handler should fire; just as if gridB's own code had dispatched the event.
Related
Does anyone know if there is any event which is thrown after ADDED_TO_STAGE event for each component?
I am executing some security actions over the components before they are shown (ADDED_TO_STAGE event), but now I need to execute some other actions after this event, but before the components are show.
So, Is it possible? Is there any event thrown in that phase.
thank you very much in advance.
I would give
Event.FRAME_CONSTRUCTED
a chance. But you have to remove the event listener after the first dispatch.
I have a problem that I have no idea to resolve it. In my application, I have a ViewStack with 2 children.
In the first view of the ViewStack, I have a datagrid with a XMLListCollection as dataprovider. In this view, user chooses a record from the datagrid then he passes to the second view.
In the second view, all the data chosen from the record will be loaded into different textInputs for modification.
My problem is, how can I pass these data from one view to another in ViewStack. I have done a search for the answer in this forum but no thread responses to my question.
All replies will be highly appreciated.
Thanks and best regards,
LE Hai-Binh
You can use Event handling mechanism. When you select a record in datagrid (in first child of Viewstack), create an Event object and put all the data into it and dispatch it. On the second child of Viewstack write a listener of this event. In the listener method extract the data from Event and do whatever you want to do with the it.
I have editable grids which are 2-way binded to my model. What I want is to validate my data when user edits any cell before it get updated in model. I have applied my validation at ItemEditEnd handler, but, I want to apply validation in between itemEditBegin and itemEditEnd events.
any ideas how to achieve this?
For this level of validation I would create a Validator for the type of data you're editing (string, number, etc.) and set the Validator's trigger to the change event of your itemEditor component.
Check out Adobe's example on using validators in an itemEditor for more info.
Update:
You may also want to check out this related question.
"In your event listener, you can
examine the data entered into the item
editor. If the data is incorrect, you
can call the preventDefault() method
to stop Flex from passing the new data
back to the list-based control and
from closing the editor."
Is there not an event that occurs only when there has been some sort of visual change to an object. So for example if it were a video or animated object it would be firing as often as EnterFrame. However, if it were some sort of input control just sitting there doing nothing visually, then the event wouldn't fire until the visual state changed as a result of some sort of user input for example.
I've tried dozen's of events and none of them seem to fire this way.
For visual components about the closest you're going to get is FlexEvent.UPDATE_COMPLETE which will fire after an object has it's commitProperties(), measure() and updateDisplayList() called. If you're subclassing the component, then overriding updateDisplayList() and handling (or throwing you're own event) in there would ensure that you're only getting the event when something visual changes.
For video, you'll want to listen to VideoEvent.PLAYHEAD_UPDATE
Is it possible to get a list of control events that are going to fire before they happen, say inside the Page_Load handler?
For example if a button was clicked can I figure this out before the button_click event handler is called?
You've picked a really tough question... the reason for this is that there are several ways that events will fire.
1) __EVENTTARGET (as mentioned above)
2) If the name of your button is MyButt, then you'll see "MyButt=" in the query string.
3) When each control (like, a TextBox for example) checks the request to see if it's value in the ViewState is different than posted, then a "Text_Changed" will fire.
But, you can use #1, and #2 to check a few places.
Unfortunately, interrogating the __EVENTTARGET value won't do the trick. Often, that value will be empty. The postback processing makes some decisions about what events to raise based on more than just the event target value (if any) testing control state values against the values posted by the form (such as for a textbox) determines whether events like TextChanged should be raised.
Aside from actually hooking up an event handler to all the controls you wish to capture events for, I don't think there is any way to determine it. It might be possible to do basically what the framework does though. You would need to do it between when the controls have been created and viewstate has been restored but before the posted values are processed. You could compare the current control values (from viewstate) with the posted values, essentially determining what events would fire.
What is your goal with this? Perhaps there is a better solution.
The following contains the mangled id for a button when clicked.
Page.Request.Form["__EVENTTARGET"]
Here is an example that I believe answers your question.
Another way would be just to set some breakpoints when debugging.