Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

26 April 2009

Tree control update after using filter function

Tree does not update when filter function is applied to dataprovider and refresh() called.

Workaround:
Reset the tree's dataprovider.

mx:tree Flex bug

22 November 2008

Flex HTTPService - how to change character set of parameters

Adobe Flex Tipp: How to change character set of parameters submitted with HTTPService object's send() method.

By default, HTTPService send parameters as name/value pairs and they are converted to URL-encoded format using UTF-8 character set.

It is possible to use system character set by adding in application
System.useCodepage = true

public static function get useCodePage reference():

Additional information

You can get the Player to fall back on making a different character set guess by setting System.useCodepage=true. So do that before executing your http service, and then after the httpservice result comes back I'd recommend setting useCodepage back to false.

Matt Chotin


Why Flex change the CharacterEncoding of HTTPSer vice's result?

You can also try somewhere in your application setting System.useCodepage = true. Normally we only support UTF-8 character sets. If you set useCodepage to true it will attempt (and sometimes get right) using another character set.



It's possible that setting this for the life of the application will have negative consequences, you may need to narrow it down to set it to true before you send the HTTPService request and set it to false after the HTTPService returns.


flexcoders

useCodePage property can be used also in other cases:
escapeMultiByte () function
Returns an escaped copy of the input string encoded as either UTF-8 or system code page, depending on the value of System.useCodePage. Use of System.useCodePage allows legacy content encoded in local code pages to be accessed by the player, but only on systems using that legacy code page.

20 August 2008

FLEX: add arrays to ArrayCollection to use as DataProvider

Web Service call return in Flex two arrays (a_RowColumn and a_RowColumnProperties) , to use these arrays as source in DataGrid we can put them in ArrayCollection and then use this ArrayCollection as DataProvider for DataGrid.

Code example:

[Bindable]
private var arrCol:ArrayCollection = new ArrayCollection();

arrCol.removeAll();
var newRow : Object;
var i:int;
for (i = 0; i < a_RowColumn.length; i++)
{
newRow = new Object();
newRow.col1 = a_RowColumn[i];
newRow.col2 = a_RowColumnProperties[i];

arrCol.addItem(newRow);
}

dg_FieldList.dataProvider=arrCol;


<mx:DataGrid x="47" y="95" width="90%" height="90%" id="dg_FieldList">
<mx:columns>
<mx:DataGridColumn headerText="Field-Number" dataField="col1"/>
<mx:DataGridColumn headerText="Field-Description" dataField="col2"/>
</mx:columns>
</mx:DataGrid>

Is there any other way to use arrays from Web Service response as DataProvider for DataGrid?

using arrays as DataProvider

Converting an array of String objects to an array of Object objects in Flex

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/03/26/converting-an-array-of-string-objects-to-an-array-of-object-objects-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">

<mx:Script>
<![CDATA[
private var arrayOfString:Array;
private var arrayOfObject:Array;

private function init():void {
arrayOfString = ["test", "test", "fork", "test"];
arrayOfObject = stringArrayToObjectArray(arrayOfString);
}

private function stringArrayToObjectArray(sourceArray:Array, key:String = "label"):Array {
var returnArray:Array = new Array();
var idx:uint;
var len:uint = sourceArray.length;
for (idx=0; idx<len; idx++) {
var obj:Object = {};
obj[key] = sourceArray[idx];
returnArray.push(obj);
}
return returnArray;
}
]]>
</mx:Script>

<mx:ApplicationControlBar dock="true">
<mx:Button label="Array of String"
click="list.dataProvider = arrayOfString;" />
<mx:Button label="Array of Object"
click="list.dataProvider = arrayOfObject;" />
</mx:ApplicationControlBar>

<mx:List id="list"
width="100"
rowCount="6"
initialize="init();" />

</mx:Application>

Arrays in ArrayCollection zusammenpacken

ArrayCollection aus Arrays

Sind es Arrays oder ArrayCollections? Wenn es normale Arrays sind, dann per concat:
Code:

var array1:Array = event.result[0] as Array; var array2:Array = event.result[1] as Array; var dp:Array = array1.concat(array2);

wenn es ArrayCollections sind dann so:
Code:

var array1:ArrayCollection = event.result[0] as ArrayCollection ; var array2:ArrayCollection = event.result[1] as ArrayCollection ; var dp:Array = array1.source.concat(array2.source);

das Array in dp kannst Du dann als dataProvider verwenden.