Hi, How can I delete a colum dynamicall?
Thanks Sanjay --- In [email protected], "Doug Lowder" <[EMAIL PROTECTED]> wrote: > > You can reassign the grid's columns property to accomplish this. > Array methods like push don't emit the events necessary for the > component to detect that the array has changed, thus the component > will not update. Try: > > public function populateData() { > // code snipped > var newCols: Array = []; > newCols.push(new DataGridColumn("col1")); > newCols.push(new DataGridColumn("col2")); > dataGrid_columns = dataGrid_columns.concat(newCols); > ... > > Reassigning dataGrid_columns to the new Array returned by the concat > () method ought to be detected by the component and cause it to > update. > > > --- In [email protected], "Paul Neyman" <paul@> wrote: > > > > Is it possible to add DataGrid columns dynamically, after DataGrid > has > > been initialized? > > > > I have the following scenario: > > > > User loads swf file with DataGrid component in it, and passes a > url as > > parameter. ActionScript code makes an HttpRequest call to this url, > > receives Xml data, parses it into columns and displays it in the > DataGrid. > > > > I do not know in advance, how many columns there will be. I tried > to > > make 'columns' array bindable and add instances of DataGridColumn > into > > it on the fly, but that has no effect on the DataGrid. > > > > While DataGrid is able to figure out itself, how many columns there > > are in a data provider, it sorts them in alphabetical order. I > need to > > set my own order. > > > > Here's a code snippet: > > > > MXML: > > > > <mx:DataGrid dataProvider="{dataGrid_data}" id = "m_dataGrid" > > columns="{dataGrid_columns}" initialize="makeCall ()"> > > </mx:DataGrid> > > > > <mx:script> > > [Bindable] > > public var dataGrid_data:ArrayCollection = new > ArrayCollection(); > > [Bindable] > > public var dataGrid_columns:Array = new Array(); > > > > public function makeCall() { > > // code snipped > > ... populateData(dataGrid_data, dataGrid_columns); > > // code snipped > > } > > > > public function populateData() { > > // code snipped > > dataGrid_columns.push(new DataGridColumn("col1")); > > dataGrid_columns.push(new DataGridColumn("col2")); > > ... > > > > // add data to provider > > } > > > > While provider works perfectly, columns array does not affect the > > DataGrid at all. Is there any workaround for this? > > > > Thanks a lot. > > >

