SharePoint List to Datagrid in Flex

The following example will show you how you can use a Button control as a custom item renderer in a DataGrid in Flex.
The XMLListCollection class provides collection functionality to an XMLList object and makes available some of the methods of the native XMLList class.

Refer article Access SharePoint List in Flex to understand how the List can be read in Flex.

XML Screenshot

MXML

<?xml version=”1.0″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”  initialize=”onCreate(event);” >
<mx:Script>
<![CDATA[
import mx.controls.Alert
import mx.collections.XMLListCollection;
import mx.collections.ArrayCollection;
private function onCreate(e:Event):void
{
var XMLLoader:URLLoader= new URLLoader(new URLRequest(“[server]/_vti_bin/owssvr.dll?Cmd=Display&List={311A4A47-E6B4-49FA-916C-900A698E1188}&XMLDATA=TRUE”))  //Replace Server with your sharePoint link
XMLLoader.addEventListener(Event.COMPLETE,openXMLValues)
function openXMLValues(e:Event):void
{ var XMLL:XMLList=new XMLList(e.target.data)
var rsNS:Namespace = XMLL.namespace(“rs”);
var zNS:Namespace = XMLL.namespace(“z”);
var sNS:Namespace = XMLL.namespace(“s”);
var Values:XMLListCollection=new XMLListCollection(XMLL.rsNS::data.zNS::row);
DG.dataProvider=Values;
}
}
]]>
</mx:Script>
<mx:DataGrid x=”21″ y=”25″ width=”596″ height=”220″ id=”DG” >
<mx:columns>
<mx:DataGridColumn dataField=”@ows_LinkFilename” />
<mx:DataGridColumn itemRenderer=”{ButtonRen}” /> </mx:columns>
</mx:DataGrid><mx:Component id=”ButtonRen”>
<mx:Button label=”Generate”  > </mx:Button>
</mx:Component></mx:Application>
To Define Component to be called in itemRenderer property

<mx:Component id=”ButtonRen”>
<mx:Button label=”Generate”  > </mx:Button>
</mx:Component>

ScreenShot

One Reply to “SharePoint List to Datagrid in Flex”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.