Would you like to react to this message? Create an account in a few clicks or log in to continue.


Pakistan is contributing at its best in the field of latest technologies, platforms and approaches. Here,Flex developers share their experience, knowledge and ideas to assure their best talent in the world.

Latest topics
» Advice sought on recruiting a Senior Flex developer in Lahore
Want to disable Combo item EmptyTue May 11, 2010 2:41 pm by anjum

» steam boiler efficency calculator
Want to disable Combo item EmptyWed Dec 23, 2009 4:55 am by imranmalik

» URLLoader and URLRequest application
Want to disable Combo item EmptyTue Dec 15, 2009 6:01 pm by imranmalik

» Time display by ILOG ELIXIER PACKAGE
Want to disable Combo item EmptyThu Dec 10, 2009 9:28 am by imranmalik

» how Filter XML data by Flash Builder
Want to disable Combo item EmptySat Dec 05, 2009 6:33 pm by imranmalik

» drag and drop (Advance Data Grid to List Box)
Want to disable Combo item EmptyThu Nov 19, 2009 7:12 pm by imranmalik

» access the xml file through HTTPService request
Want to disable Combo item EmptySun Nov 15, 2009 11:46 am by imranmalik

» CURRENCY VALIDATOR
Want to disable Combo item EmptyTue Nov 03, 2009 2:06 pm by imranmalik

» Synchronous Behavior
Want to disable Combo item EmptySun Nov 01, 2009 8:04 pm by imranmalik

Social bookmarking
Social bookmarking reddit      

Bookmark and share the address of on your social bookmarking website


You are not connected. Please login or register

Want to disable Combo item

2 posters

Go down  Message [Page 1 of 1]

1Want to disable Combo item Empty Want to disable Combo item Wed Oct 28, 2009 1:31 pm

kamran

kamran
Admin

I want to disable a combo item or items in flex, so the user can only view an item, but not able to select it.

2Want to disable Combo item Empty Re: Want to disable Combo item Wed Oct 28, 2009 2:51 pm

anjum

anjum

http://DisabledComboBox.as
package pk.com.flexpak.controls
{
/**
* DisabledComboBox.as
*/
import mx.controls.ComboBox;
import mx.core.ClassFactory;
import mx.events.FlexEvent;

public class DisabledComboBox extends ComboBox
{
/**
* Constructor.
*/

public function DisabledComboBox()
{
super();
this.dropdownFactory = new ClassFactory(DisabledList);
this.itemRenderer = new ClassFactory(DisabledListItemRenderer);
}

/**
* @private
*/
override public function set dataProvider(value:Object):void
{
super.dataProvider = value;
moveToEnable();
}

private function moveToEnable():void {
var i:int = -1;
for each (var obj:Object in dataProvider) {
i++;
if (this.selectedIndex == -1) {
this.selectedIndex = 0;
}
if (i < this.selectedIndex) {
continue;
}
if (obj != null
&& ((obj is XML && obj.@enabled == 'false')
|| obj.enabled==false || obj.enabled=='false')){
if(i == this.selectedIndex){
this.selectedIndex++;
}
}
}
if (this.selectedIndex > i) {
this.selectedIndex = 0;
}
}

override public function initialize():void
{
this.toolTip = this.text;
if (initialized)
return;
createChildren();
super.initialize();
}

/**
* @private
* Make sure the drop-down width is the same as the rest of the ComboBox
*/
override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
this.toolTip = this.text;
}

private function textInput_valueCommitHandler(event:FlexEvent):void
{
// update _text if textInput.text is changed programatically
super.text = textInput.text;
dispatchEvent(event);
}

private function textInput_enterHandler(event:FlexEvent):void
{
dispatchEvent(event);
dispatchEvent(new FlexEvent(FlexEvent.VALUE_COMMIT));
}
}
}
//------------------------------------------
package pk.com.flexpak.controls
{

import mx.controls.Label;

public class DisabledListItemRenderer extends Label
{
private var _enabled:Boolean = true;

/**
* Constructor.
*/
public function DisabledListItemRenderer()
{
super();
}

/**
* @private
*/
override public function set data(value:Object):void
{
if (value != null && ((value is XML && value.@enabled == 'false')
|| value.enabled==false || value.enabled=='false')){
this._enabled = false;
}else{
this._enabled = true;
}
super.data = value;
}

override protected function updateDisplayList(unscaledWidth:Number,
unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (!this._enabled) {
textField.setColor(getStyle("disabledColor"));
}else{
textField.setColor(getStyle("color"));
}
}
}
}
please visit this link for more detail

http://wmcai.blog.163.com/blog/static/4802420088945053961/

https://flexpakistan.board-directory.net/

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum