flex DateChooser needs to not be selectable - actionscript-3

I'm sure this is pretty easy but I'm at a loss with this one. I have a DateChooser that I'm using to highlight dates when things are being released. And that's all I want it for. I want to turn off the ability for users to click on anything. I don't see how to have selectable false. Anyone know?
Thanks

There are actually two properties that you can use to turn off user interaction:
First is the enabled property, set it enabled="false" in mxml and user
interaction will be disabled. However, Flex will render the
DateChooser dim (kind of faded away).
<mx:DateChooser id="date1" enabled="false" />
Another option is the mouseChildren property, if you set it to
mouseChildren="false" as well all children of the display object will not be enabled, in the case of the DateChooser it disables all user interaction too.
<mx:DateChooser id="date1" mouseChildren="false" />

Try placing it behind a Group that has a fill with alfa 0. That way the group will take the clicks and do nothing with them.

If i understand you correctly, then you could use the disabledDays, disabledRange or selectableRange properties of the DateChooser. E.g. such as in the code from the adobe website:
<mx:DateChooser
selectableRange="{{rangeStart: new Date(2006,0,1),
rangeEnd: new Date(2006,2,15)}}"
disabledRanges="{[new Date(2006,0,11),
{rangeStart: new Date(2006,0,23), rangeEnd: new Date(2006,1,10)}]}"
disabledDays="{[0,6]}"/>
Use this to disable all other dates than the one(s) you want highlighted. I was actually just wondering if i should do something similar, but I just ended opp using a disabled DateField(enabled=false) to display the date. I hope this helps :)

Related

Force GridView To Create Not Recycle Controls

I have a GridView in a windows store app that has an ItemContainerStyleSelector. Within the style is an Image control that has a custom dependency property to set the source (This is so I can get a handle on the Image and hook up to the unloaded event).
My issue is the Image is never unloaded and seems to be reused. This means that when I set the source, the image is set on other items in the GridView as well (For Example I have an object which has no image but after scrolling away and then back again it has an image from another object).
I've tried to set virtualization mode to standard where I can but it doesn't help. Any ideas would be greatly appreciated.
Here is the Image that is contained in the style. This is passed to a method "OnRemoteURISourceChanged" when set. I'd expect a different image control whenever the method is called but this is not the case.
<Image x:Name="BackgroundImage" DataContext="{Binding CurrentBackdrop}" helpers:ImageExtensions.RemoteURISource="{Binding Uri}" Stretch="UniformToFill"/>
And here is my GridView
<GridView x:Name="ItemsGrid" Grid.Row="1" ItemsSource="{Binding BrowseResults}" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" Margin="20,0,20,0"
IsItemClickEnabled="True" ItemClick="ItemsGrid_ItemClick" VirtualizingStackPanel.VirtualizationMode="Standard">
<GridView.ItemContainerStyleSelector>
<controls:UPnPCDStyleSelector CDObject="{StaticResource somestyle1}" Container="{StaticResource somestyle2}" Item="{StaticResource somestyle3}"/>
</GridView.ItemContainerStyleSelector>
<GridView.ItemsPanel>
<ItemsPanelTemplate VirtualizingStackPanel.VirtualizationMode="Standard">
<WrapGrid Orientation="Vertical" VirtualizingStackPanel.VirtualizationMode="Standard"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>
UPDATE: The issue appears to be the WrapGrid. If I change this to a VirtualizingStack Panel and set the VirtualizationMode to Standard then everything works as expected but obviously my items then only appear on one line and not multiple lines as I wish.
How do I set the virtualization mode of a WrapGrid?
Is there a chance your helpers:ImageExtensions.RemoteURISource doesn't clear the Image.Source when either your CurrentBackdrop property or its Uri property value is null?
Are you sure the task which is loading the img source returns to default ui context when awaiting? I don't think it is a good idea to set Image.Source property form code. The better solution would be to create a custom observable task class and bind im source to it's result. In the background you can call the task. Do you need the control to be Image? Because if it would be a control with template, it would be easier for you to do that. I can send you the class which does that if you want to.

MVC3/Razor - Disabled options in select tag don't post back

I have a Employee entity that I'm binding to an "Edit" view in an MVC3/Razor application. The Employee entity has a property for OccupationTypeId. OccupationTypeId points to the OccupationType table which contains several lookup values. The natural choice would be to use #Html.DropDownListFor to render a <select> tag containing a list of Occupations.
The OccupationType table schema is fairly standard: Id, Name, Description, IsEnabled. Since OccupationTypes can be disabled, I want the OccupationTypeId drop down to still render disabled options so the user can always see their selection if it's disabled, but a disabled option can't be selected by the user. In other words, a user can't change an existing OccupationTypeId to a disabled option.
I thought about creating a #Html extension method to build my <select> tag with the options and simply tack on a disabled attribute to disabled options. I think that would be straight forward...
However, disabled selected options don't seem to post back to the controller method. In other words, Employee.OccupationTypeId would be null when I post to Edit.
Is there any way to change this behavior or is this built in to MVC 3? I thought about using hidden fields, but what if OccupationTypeId is required and I have validation enabled?
Has anyone else faced this?
Thanks
You could have a hidden field that gets updated when the change event occurs in the dropdown list. This way the OccupationTypeId field is always passed.
<input name='CurrentOccupationId' type='hidden' value='#Model.Employee.OccupationTypeId' />
<script>
$(function() {
$('#dropDownId').change(function() {
$('input[name="CurrentOccupationTypeId"]').val($(this).val());
});
});
</script>
Is there any way to change this behavior or is this built in to MVC 3?
I thought about using hidden fields, but what if OccupationTypeId is
required and I have validation enabled?
It has nothing to do with MVC 3 in particular; all disabled html elements don't post back in general.
The solution I've used is to "simulate" the disable element by styling the appropriate element with CSS. You can, for example, set the element's background (or foreground) color to gray and set the readonly attribute (when it makes sense) instead.
See this similar thread.

How can you make a Datagrid's Image-based itemRenderer either visible or not, depending on the value of its row and column in the datagrid?

The description is basically the same as the title. This is a related post I made a little while ago: Why would an Image-based itemRenderer always be visible? Basically the dataField that's being used for the itemRenderer's column in this case is "ongoing", and I want to set the itemRenderer and/or its image to true or false, depending on the value of ongoing in that row. If the itemRenderer is Label-based, I'm able to set the text to different values, depending on that. Certain specific properties, like visible, are problematic though. Documentation I've found so far on using states is very difficult to follow, and I'm not even sure those apply here. How do I do this? The current code, by the way is as follows:
<mx:DataGridColumn dataField="ongoing" id="ongoing" headerText="">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="logo.jpg">
<mx:Script>
<![CDATA[
override public function set data(value:Object):void {
super.data = value;
super.visible = (value.ongoing != 'False');
}
]]>
</mx:Script>
</mx:Image>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
I've also tried working with the set visible override. Thanks!
That doesn't make any sense, especially in a Datagrid. If you don't want to display data, filter for it using a collection's filter function. Otherwise you're having empty cells.
Also, you're working against the component live cycle:
Setting visible in data will be called before the component is actually rendered - so there is no effect. If you're using vanilla objects and no classes, changes of the property's value will not have any effects as well.
On a site note: Boolean should be Booleans, no Strings and inline renderers can lead to some scoping issues, that's why i'd recommend using a separate component definition (aka .as or .mxml file).
The answer can loosely be found here by gokiさん:
http://www.fxug.net/modules/xhnewbb/viewtopic.php?topic_id=2229
At the moment at least, I'm having to actually set the source to either the image or a blank string to get this to work (looked like he was trying to do something slightly different), but it works.
EDIT: These two lines of code replaced where he was messing with the visible property:
var property0:SetProperty = new SetProperty(this, "source", "");
var property1:SetProperty = new SetProperty(this, "source", "dot.png");

active content property on tab change

I want to create binding in code that will jump when the user is navigating between tabs,
or when ever a tab is created.
I tried to bind the dependency property active content property, and from some reason it doesn't work.
thanks.
What may help is to explicitly set a TwoWay binding:
<avalondock:DockingManager ActiveContent="{Binding DocumentManager.ActiveDocument,
Mode=TwoWay}" />

ColorPicker not editable in Form -> FormItem

Please note the remark mentioned WORKAROUND at the end of this question.
Based on a Dictionary based specification, one of my classes creates a Form programmatically.
Adding TextInput or DatePicker to FormItemss works as expected.
Unfortunately, the following code just creates a colored rectangle, not the actual picker:
ti = new ColorPicker();
ColorPicker( ti ).selectedColor = TAColor( _spec[ key ].value ).color;
and later on
formItem.addElement( ti );
The Form is embedded in a TitleWindow component presented using
PopUpManager.addPopUp(...);
When added to TitleWindow, it shows up correctly, within Form->FormItem not:
I can't image, why the picker doesn't appear. Do you?
WORKAROUND:
If I wrap the ColorPicker inside a Group things work:
ti = new Group();
Group( ti ).addElement( new ColorPicker() );
In this case, the ColorPicker appears as editable.
Still, I'd be too happy to learn what the problem with my initial solution. Bug?
A DateField (which extends ComboBase like ColorPicker) behaves properly in a spark Form. But in the ColorPicker, the mouse down handler of the button never gets called. I think that maybe the skin part that handles the mouse clicks (it must be a button) is not properly dimensionned, and the result is it is not shown. I've come to this conclusion because within an mx Form, the ColorPicker doesn't display as it does when it is added to the regular displaylist...
Hope this helps...
In the code you've provided, you never add the colorPicker as a child to any parent container; as such it will never show up anywhere.
You probably need to do something like:
formItem.addChild(ti );
[or for a Spark formItem]:
formItem.addElement(ti );
I'm confused as to why you're seeing a rectangle.