Sometime we need to access the protected properties of the class. e.g. the TextField of a TextInput control.
You can access the such properties by subclassing the class.
package com
{
import mx.controls.TextInput;
import mx.core.IUITextField;
public class MyTextInput extends TextInput
{
public function MyTextInput()
{
super();
}
public function get myTextField():IUITextField
{
return this.textField;
}
}
}
The same property can be accessed without extending the class, using the internal namespace. ;)
import mx.core.mx_internal;
use namespace mx_internal;
private function getMyTextFild():void
{
var tf:IUITextField = ti.mx_internal::getTextField();
// ti is textinput control
}
Thursday, May 21, 2009
Flex: Accessing protected properties and internal namespace
Friday, May 15, 2009
DataGrid Search usign filterFunction
Following example uses filterFunction on the ArrayCollection.
You can view the example here Search DataGrid
You can view the example here Search DataGrid
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.events.IndexChangedEvent;
import mx.collections.ArrayCollection;
[Bindable]
private var dp:ArrayCollection = new ArrayCollection([{name:'rahim',add:'fdsds dfdsfsd sf sdf sf '},
{name:'sanket',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Rahim',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Satish',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Vikas',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Jagtap',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Ravi',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Raju',add:'fdsds dfdsfsd sf sdf sf '},
{name:'Parvez',add:'fdsds dfdsfsd sf sdf sf '},
]);
private var tempdp:ArrayCollection;
private function changeHandler(e:Event):void
{
e.stopImmediatePropagation()
if(txtSearch.text == '')
{
dp.filterFunction = null;
}else
{
dp.filterFunction = nameFilter;
}
dp.refresh();
}
private function nameFilter(item:Object):Boolean
{
return item.name.toLowerCase().indexOf(txtSearch.text.toLowerCase())!=-1;
}
]]>
</mx:Script>
<mx:DataGrid x="10" y="87" dataProvider="{dp}" id="dg">
<mx:columns>
<mx:DataGridColumn headerText="Column 1" dataField="name"/>
<mx:DataGridColumn headerText="Column 2" dataField="add"/>
<mx:DataGridColumn headerText="Column 3" dataField="col3"/>
</mx:columns>
</mx:DataGrid>
<mx:TextInput id="txtSearch" x="58" y="38" change="changeHandler(event)"/>
</mx:Application>
Subscribe to:
Posts (Atom)