• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1068
  • Last Modified:

FLEX AdvancedDatagrid Column visibility

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.

Thanks
0
VKN9876
Asked:
VKN9876
  • 3
1 Solution
 
Jones911Commented:
Show some of your code and we'll take a look.
0
 
zzynxSoftware engineerCommented:
The class AdvancedDataGridColumn has a property visible that you can set true or false
0
 
zzynxSoftware engineerCommented:
This small app should give you quite some inspiration
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				layout="vertical"
				verticalAlign="middle"
				backgroundColor="white"
				creationComplete="onCreationComplete()">
 
	<mx:Script>
	<![CDATA[
		import mx.controls.Alert;
		import mx.collections.ArrayCollection;
 
		[Bindable]private var arrayOfString:Array;
 
		[Bindable]
		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:Script>
 
	<mx:AdvancedDataGrid id="myGrid">
            <mx:columns>
                <mx:AdvancedDataGridColumn id="priceColumn" dataField="Price"/>
                <mx:AdvancedDataGridColumn id="storeColumn" dataField="Store"/>
                <mx:AdvancedDataGridColumn id="artistColumn" dataField="Artist"/>
			</mx:columns>	
	</mx:AdvancedDataGrid>
	
	<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" />
 
</mx:Application>

Open in new window

0
 
zzynxSoftware engineerCommented:
Thanx 4 axxepting
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now