Flex DateChooser events for individual days? - apache-flex

I'm using a DateChooser, and want to show different information in a tooltip as the user rolls over each day. Is there an event that fires as I'm rolling around the calendar that will tell me what day I'm currently over?

It's a little complicated. You're going to need to use the mx_internal namespace. The grid portion of the DateChooser component is a CalenderLayout component in DateChooser.as.
mx_internal var dataGrid:CalenderLayout;
CalenderLayout.as has the mouseMoveHandler. In the handler we have:
var selCell:IUITextField = dayBlocksArray[colIndex][rowIndex];
that gives you the necessary info about which day the mouse is over. You will need to extend DateChooser to use an extended CalendarLayout that exposes the selectedCell.
perhaps:
private function mouseMoveHandler(event:MouseEvent):void
{
...
dispatchEvent(new DayHoverEvent(selCell.text));
}
I guess what I'm trying to say is it's kinda tricky, and it uses mx_internal, which means the variables are subject to change in later versions of Flex.

What about change?

You may want to check out my blog post on this: http://flexmonkey.blogspot.com/2010/06/displaying-color-coded-events-in-flex.html
I've based this on some previous work by Kevin Brammer (http://www.cyberslingers.com/weblog/post/Adding-Calendar-Event-Entries-to-the-Flex-DateChooser-Component.aspx) - it allows you to add a tooltip to individual days and colour code them
Hope it helps,
simon

Related

Getting Event data within a CustomView after setRange is called

So I'm trying to build my own custom view for a month's worth of data (based on the "agenda-views.html' example) and I've been able to create a custom View class which adds itself as a button on the list of .. buttons.
When I click on that button (MyView), its setRange is called so I know the range of Events to display.
The View's renderEvents is called but is passed all of the Events that the Calendar knows about, so I have a two parter question:
(a) Is there a way I can use existing code to do the equivalent of: "given this range, give me all of the Events fullCalendar knows about"?
- or -
(b) Do I use an XHR here to pull back the data for the given range (now that I know what it is is) and Render it
I'd rather do (a) as it's more efficient (less requests etc) but I'm finding myself swamped in code and, after reading through quite a lot it haven't really found a method that says 'Get all events for this range'.
Alternatively, am I missing something? How does renderEvents know what the current range is and then render them? Or, should I be using renderSelection, which doesn't seem to get called.
Thanks!
Set up your events as a json feed, when the URL is called it will pass the start and end dates for the current view. In your function/method/action you then retrieve your events for the given dates and return them.

How to set focus on specific activity in flexganttfx

I'm using Flexganttfx, and I'd like swipe to an specific activity in my gantt chart when I click in a term (this term is out gantt chart, but contains the reference for the activity object that I want to swipe to).
How to do this?
I found the answer into the flexganttfx's forum:
"there is no utility method for doing this, yet. You will need to call scrollTo() on the tree table view and then request a specific time on the timeline (Timeline.showTime())."
http://dlsc.com/forums/topic/setselectedactivity-scroll-to-row-and-activity/
In my case:
int rowIndex = gantt.getTreeTable().getRow(treeItem);
gantt.getTreeTable().scrollTo(rowIndex);
gantt.getTimeline().showTime(date);
This solves my problem, I hope to help someone :)

Refresh feature with Openlayers 3

Is it possible to refresh a single feature of a vector layer with Openlayers 3? I don't want to refresh all the layer.
If you have a reference to the feature, you can update aspects of the feature like it's geometry or properties and that will be updated in the map.
setGeomtry and setProperties both fire events that make the map update:
http://openlayers.org/en/latest/apidoc/ol.Feature.html
As long as you have set things up so that you can find or keep a direct reference to the feature, you can use the methods detailed in http://openlayers.org/en/latest/apidoc/ol.Feature.html to update a feature
If you are using the ol vector source, you can try to remove the feature and add it again. The Add Feature function triggers a change event (for the whole source, but this shouldn't update already drawed features).
ol.source.Vector.prototype.addFeature = function(feature) {
this.addFeatureInternal(feature);
this.changed();
};

stack overflow on XMLListCollection collectionEvent

I'm working on a Flex 3 project, and I'm using a pair of XMLListCollection(s) to manage a combobox and a data grid.
The combobox piece is working perfectly. The XMLListCollection for this is static. The user picks an item, and, on "change", it fires off an addItem() to the second collection. The second collection's datagrid then displays the updated list, and all is well.
The datagrid, however, is editable. A further complication is that I have another event handler bound to the second XMLLIstCollection's "change" event, and in that handler, I do make additional changes to the second list. This essentially causes an infinite loop (a stack overflow :D ), of the second lists "change" handler.
I'm not really sure how to handle this. Searching has brought up an idea or two regarding AutoUpdate functionality, but I wasn't able to get much out of them. In particular, the behavior persists, executing the 'updates' as soon as I re-enable, so I imagine I may be doing it wrong. I want the update to run, in general, just not DURING that code block.
Thanks for your help!
Trying to bind the behaviour to a custom event rather than the CHANGE event.
I.e. do what you are doing now, but dispatch and handle a custom event to do the work.
Have you considered using callLater?
Does direct manipulation of XMLListCollection's source XMLList have the same results?
Have you considered something like:
private function changeHandler( event:Event ):void
{
event.target.removeEventListener( event.type, changeHandler );
// your code here.
event.target.addEventListener( event.type, changeHandler );
}

Flex - Is there a way to specify what direction a ComboBox will open?

Maybe I should further qualify this - Is there a way to specify which direction a ComboBox will open without copying and pasting the entire ComboBox class and ripping out the code where it determines which direction it will open in...
I'm my specific case - I need it to open upwards - always.
UPDATE: You can't fix this by subclassing it because the function that handles the direction of the opening is:
private function displayDropdown(show:Boolean, trigger:Event = null):void
And that bad boy uses a fair amount of private variables which my subclass wouldn't have access to...
If you build up the Menu object yourself, you can place the menu anywhere you want by simply setting the x,y coordinates of the menu object. You'll need to calculate those coordinates, but you might be able to do this easily without subclassing ComboBox.
I am doing something similar with PopUpButton; you might find it easier to work with PopUpButton. This is based on real code from my current project:
private function initMenu(): void {
var m:Menu = new Menu();
m.dataProvider = theMenuData;
m.addEventListener(MenuEvent.ITEM_CLICK, menuClick);
m.showRoot = false;
// m.x = ... <-- probably don't need to tweak this.
// m.y = ... <-- this is really the interesting one :-)
theMenu.popUp = m;
}
<mx:PopUpButton id="theMenu" creationComplete="initMenu()" ... />
BTW, to get the PopUpButton to act more like I wanted it (always popup, no matter where the click), setting openAlways=true in the MXML works like a charm.
I doubt it - you'd need to subclass the control (which isn't that big a deal.)
Maybe you could mess with the real estate so it's placed in such a fashion (e.g. crowded into the lower right corner) that up is naturally coerced?
I would recommend checking out this post. Yes, you do have to grab the ComboBox code and modify it, but at least now you have an idea where the modifications need to go.
You could set the MaxDropDownHeight, if you set it big enough Windows will automatically set the direction upwards.
This irritated me no end. I have uploaded a solution, its a simple Class that extends the PopUpButton and removes the logic of stage bounds detection as it failed 50% of the time anyway. My code just allows you to simply specify whether you want to open the menu up or down:
http://gist.github.com/505255

Resources