This content has been marked as final. Show 4 replies
Don't set the width to 0, instead just don't add the data to the grid.
Before setting the grid's dataProvider, set your columns like so:
var ord:DataGridColumn = new DataGridColumn("Order");
ord.width = 40;
ord.headerText = "Order:";
When you make the new column the field name should match that being returned
from the database.
So, you'll have a group of these statements, that set the columns in your
grid. Columns in the dataProvider that don't match are simply not displayed.
Yet you can still get any columns in the dataProvider:
Adobe Community Expert
A simple approach I have used in the past does involve setting a column
width to zero... only completely hides if you also set the columns
"resizeable" property to false as well...
dg.getColumnAt(i).resizable = false;
> Dear Forum
> I'd like to hide a column in a datagrid? I'm getting ID's from the database
> that the user doesn't need to see but that are necessary to communicate back
> with the database. I'm using the dataGrid component to list the content.
> Is it possible to hide the ID column in the dataGrid? I've tried setting the
> width to 0 without luck. Also the visible parameter doesn't seem to compile.
> I've attached a snippet of the code.
> Any help appreciated.
> Thank you very much
> var dgCol_order:DataGridColumn = dg.addColumn("Order");
> var dgCol_cat:DataGridColumn = dg.addColumn("Category");
> var dgCol_sess:DataGridColumn = dg.addColumn("SessionID");
> dg.getColumnAt(0).width = 0;
> dg.getColumnAt(1).width = 200;
> dg.getColumnAt(2).width = 0;
> dgCol_order.visible = false;
> dgCol_sess.visible = false;
Thank you to both of you.
I've followed your advice and didn't even display the data in the set but I've added it to the dataprovider. When I select the row I can retrieve the data with myGrid.selectedItem.id. Works perfectly!
> Thank you to both of you.
> I've followed your advice and didn't even display the data in the set but I've
> added it to the dataprovider. When I select the row I can retrieve the data
> with myGrid.selectedItem.id. Works perfectly!
> Thanks again