Hi have done it by giving an id to the colum and sets its visible property to hide/show that purticular column.
Thank, Sanjay --- In flexcoders@yahoogroups.com, Jeff Tapper <[EMAIL PROTECTED]> wrote: > > something like this should work (note, this code is off the top of my head > and not tested) > var colArray:Array = dg.columns; > // remove column 3 > var newColArray = colArray.splice(3,1); > dg.columns = newColArray; > > At 12:00 PM 2/4/2007, sanjaypmg wrote: > > >Hi, > > > >How can I delete a colum dynamicall? > > > >Thanks > >Sanjay > > > >--- In <mailto:flexcoders% 40yahoogroups.com>flexcoders@yahoogroups.com, > >"Doug Lowder" <douglowder@> > >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 <mailto:flexcoders% 40yahoogroups.com>flexcoders@yahoogroups.com, > > "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. > > > > > > > > > > > > > Jeff Tapper > Founding Partner > Tapper, Nimer and Associates Inc. > [EMAIL PROTECTED] > (718) 576-1775 >