You need to make it hardcoded, as you hard code the dataField for every column.
Else you need to make use of regex and apply it to the XML to make out your nodes for the headers. Good practice is not to pouplate it like this, instead make proper VOs and populate them with your data XML. Your work will be more structured and then you have control over the things you mentioned. Thanks, Vaibhav Seth. EMAILING FOR THE GREATER GOOD Join me To: [email protected] From: [email protected] Date: Thu, 21 Jan 2010 11:55:41 -0800 Subject: [flexcoders] How to dynamically populate the Header Text of Flex Datagrid from XML or from an arrayCollection Hi, I currently return an XML File(below) to Flex and have been assigning it to an array collection in order to populate a data grid. As of now i have the header Text hardcoded . I want to put it dynamically from the arraycollection below, and some timee there are some of the columns need to hide and show too.How can i do this? var xLabels:Array = (Xs[0].label as Array); labels = new ArrayCollection(xLabels); var hObj:Object=new Object(); for (var lObj:int=0; lObj < labels.length; lObj++) { hlabel =labels[lObj]; } public var arrRawData:ArrayCollection = new ArrayCollection(); __model.arrNewData = event.result.rawdata.record as ArrayCollection; var xmlResult:XML = XML(event.result); Any help would be greatly appreciated. Thanks, blue 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: <rawdata> <record> <Service>Ser1</Service> <Health>1<Health> <Availability>100%<Availability> <Risk>2</Risk> </record> <record> <Service>Ser1</Service> <Health>1<Health> <Availability>100%<Availability> <Risk>2</Risk> </record> <record> <Service>Ser1</Service> <Health>1<Health> <Availability>100%<Availability> <Risk>2</Risk> </record> <record> <Service>Ser1</Service> <Health>1<Health> <Availability>100%<Availability> <Risk>2</Risk> </record> </rawdata>

