I have a itemrenderer in datagrid and I am trying to get the instance of itemrender in datagrid keypressevent as follows
var col:DataGridColumn = _datagrid.columns[_datagrid.selectedCells[0].columnIndex];
var myItemrend:MyItemrender = col.itemRenderer as MyItemrender;
But the above myItemrend instance is null. How can I get the itemrenderer instance.
Please help.
Thanks,
Rejeev.
I have an itemrenderer in Datagrid and it is used as itemeditor also by rendererIsEditor=true. My itemrenderer has a textinput and a list, where I open the list, for editing, when a focusin event is occurred in textinput, this happens while clicking the cell.
I need the same editing to happen while I enter using the keyboard(Enter), so I am trying to get the instance of the itemrender in Keyboard.ENTER and using this I can dispatch the textinput focusin event.
Thanks,
Rejeev.
Related
Is it possible to add an event listener for Alert.show?
So that every time an alert box is shown I can call a function to hide an iframe.
I think you will get stuck since event dispatching/listening will require using an instance of a class to be the dispatcher, which is not the case when using the static .show().
However, I guess you could manually dispatch an event every time you want to close your iframe and display an alert (both could be done by the event dispatched).
You could as well create your own class that would have a .showAlert function performing both the event dispatching and the regular Alert.show(). This requires your custom class to be instantiated but the instance could also be stored in a Singleton so you don't have to recreate a new one every time you want to display your Alert.
Alert.show will return you the instance of the alert object. Use the object to add event listeners on the alert.
var alert:Alert = Alert.show("contente");
alert.addEventListener(Event.Close, function(e:Event):void{
// TODO
);
I'm using a custom item renderer in my datagrid, and need to make a button visible or invisible based on if there has been a negative value on any of the values in the renderer. So I'd like to set a flag to false when the first renderer is set off, turn it to true if there's any negative values, and at the end check for the value of the flag. I know I can dispatch a dataChange event for every time the data is changed in the renderer instances, but I was wondering if there is anyway I can know when all of them are done?
Thanks!
There is no such event.
Like any other Flex component, a renderer will dispatch a CREATION_COMPLETE after it's been created. ItemRenderers are generally recycled (the same object gets assigned new data to render), thus listening for CREATION_COMPLETE is not sufficient, unless you disable the recycling.
For a Spark List component, you can disable recycling by setting useVirtualLayout=false on the layout class. I'm not sure if the Spark DataGrid class support this or not. The MX DataGrid may have some other way to do this.
Disabling the recycling, however, can have performance implications. I think your idea w/the DATA_CHANGE event is the best solution:
determine the initial state of the data (ie: are there any negative values)
in the renderer, use the DATA_CHANGE event (or just override the setter for the renderer's data property) to know when the data has changed
When the data changes, dispatch a custom event class that will bubble. This event has a property that tells you if the value is negative or not.
Since your custom event from the renderers will bubble up to the grid, you can add one listener on the grid to handle changes from all the renderers.
You should have a look into RendererExistenceEvents. You should be able to tell when they are all created based on how many items you have in your list or at least how many should be in view at once.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/events/RendererExistenceEvent.html
I have a case where the SelectedItem isn't called after the data provider changes for
a dropdownlist.
is there a way to detect if such a change occurred?
Thanks
Just about every public property in the Flex Framework has a 'propertyChanged' event that is dispatched from the properties set method. They are used primarily for binding purposes, but not usually formally documented.
The dataProvider set method of a DropDownList does indeed dispatch a dataProviderChanged event. The code is several layers up in the hierarchy, as part of SkinnableDataContainer or if the skin for your 'SkinnableDataContainer' has a dataGroup it is dispatched from the DataGroup.
But, this event will probably will not be exposed via code hinting in MXML. You'll have to listen for it in ActionScript:
myList.addEventListener('dataProviderChanged', onDataProviderChanged);
Keep in mind this event will always be dispatched when the dataProvider changes, regardless of what happens to the selectedItem property.
You can listen to changes in the selectedItem in a DropDownList through the IndexChangeEvent, illustrated by the code below:
<s:DropDownList id="dl_mydl"
dataProvider="{dataProvider}"
change="dropDownListChangeHandler(event)"
/>
protected function dropDownListChangeHandler(event:IndexChangeEvent) : void
{
//DO SOMETHING
}
I have a mediated view with a DataGroup with a custom ItemRenderer. I want when I click a button in the ItemRenderer to dispatch a signal and handle it in my mediator? How can I do that?
Thanks in advance
In your item renderer dispatch an event that bubbles, then on your DataGroup add a listener for that event (in your mediator).
I am working on a datagrid with custom itemRenderer & [Bindable]xmllist as dataprovider. Now the changes done in xmllist are not reflected on datagrid UI until unless I re-assign the dataprovider as the same xmllist.
As the dataprovider is Bindable so re-assigning is not required.
But it was not working so I re-assigned the xmllist to the dataprovider of datagrid. It worked.
Now my problem is when I re-assign the dataprovider my datagrid flicker(refreshes). It should not happen.
1) Is there any way out to avoid re-assigning of dataprovider?
2) Is there any way to stop flickering of datagrid on re-assigning the dataprovider?
Thanks in advance.
I think xmlList, along with xml are not able to be bound for whatever reason, so binding doesn't work with them. You could convert your xmlList to an arrayCollection and bind to that. The flicker would probably have something to do with your custom itemRenderer, but I think we would need to see the code to know more.