FLEX AdvancedDatagrid Column visibility

Posted on 2009-02-11
Last Modified: 2012-05-06
Hi All,

I'm have a datagrid with 30 columns and trying to set the visibility on and off programatically. I want to make sure atleast one column should be visible in the datagrid (i.e. the user can set the visiblity off only on 29 columns max). How this can be done?
I tried with countColumns but always the count is returning max number of columns.

Question by:VKN9876
    LVL 19

    Expert Comment

    Show some of your code and we'll take a look.
    LVL 37

    Expert Comment

    The class AdvancedDataGridColumn has a property visible that you can set true or false
    LVL 37

    Accepted Solution

    This small app should give you quite some inspiration
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx=""
    		import mx.controls.Alert;
    		import mx.collections.ArrayCollection;
    		[Bindable]private var arrayOfString:Array;
    		public var dgArray:ArrayCollection = new ArrayCollection([
    			{Price:'Lots', Store:'yahoo', Artist:'Jack'},
    			{Price:'None', Store:'amazon', Artist:'Jill'}
    		private function onCreationComplete():void {
    			myGrid.dataProvider = dgArray;
    			pChk.selected = priceColumn.visible;
    			sChk.selected = storeColumn.visible;
    			aChk.selected = artistColumn.visible;
    		private function updateCheckBoxes(): void {
    			pChk.enabled = !( !aChk.selected && !sChk.selected );
    			sChk.enabled = !( !aChk.selected && !pChk.selected );
    			aChk.enabled = !( !pChk.selected && !sChk.selected );
    	<mx:AdvancedDataGrid id="myGrid">
                    <mx:AdvancedDataGridColumn id="priceColumn" dataField="Price"/>
                    <mx:AdvancedDataGridColumn id="storeColumn" dataField="Store"/>
                    <mx:AdvancedDataGridColumn id="artistColumn" dataField="Artist"/>
    	<mx:CheckBox id="pChk" click="{priceColumn.visible=!priceColumn.visible; updateCheckBoxes()}" label="Price column visible" />
    	<mx:CheckBox id="sChk" click="{storeColumn.visible=!storeColumn.visible; updateCheckBoxes()}" label="Store column visible" />
    	<mx:CheckBox id="aChk" click="{artistColumn.visible=!artistColumn.visible; updateCheckBoxes()}" label="Artist column visible" />

    Open in new window

    LVL 37

    Expert Comment

    Thanx 4 axxepting

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
    This post first appeared at Oracleinaction  ( Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now