Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is simple example how to display CSV data in flex. The code doesn't contain any failover functionality and it is just for illustration of the solution.</p> <ol> <li>Data is loaded via URLLoader in function loadData.</li> <li><p>Retrieved data is processed in function processData. It is split into rows. Each row is converted to array (again by split) and the result is pushed to output array, which is assigned as data provider of the grid. Grid has defined columns with data fields matching to indexes in the arrays converted from the rows.</p> <pre><code>&lt;mx:Application name="CSVTest" xmlns:mx="http://www.adobe.com/2006/mxml" applicationComplete="loadData();"&gt; &lt;mx:Script&gt;&lt;![CDATA[ private var dataLoader:URLLoader; private function loadData():void { dataLoader = new URLLoader(new URLRequest("data.csv")); dataLoader.addEventListener(Event.COMPLETE, parseData); } private function parseData(event:Event):void { var output:Array = []; var input:String = dataLoader.data; var rows:Array = input.split("\n"); for (var i:int = 0, len:int = rows.length; i &lt; len; i++) { var row:Array = String(rows[i]).split(","); output.push(row); } grid.dataProvider = output; } ]]&gt;&lt;/mx:Script&gt; &lt;mx:DataGrid id="grid"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn dataField="0"/&gt; &lt;mx:DataGridColumn dataField="1"/&gt; &lt;mx:DataGridColumn dataField="2"/&gt; &lt;mx:DataGridColumn dataField="3"/&gt; &lt;mx:DataGridColumn dataField="4"/&gt; &lt;mx:DataGridColumn dataField="5"/&gt; &lt;mx:DataGridColumn dataField="6"/&gt; &lt;mx:DataGridColumn dataField="7"/&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; &lt;/mx:Application&gt; </code></pre></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload