4 Replies Latest reply on Apr 14, 2010 9:26 AM by odd_job08

    Flex 3 - configurable column selection for AdvancedDataGrid

    odd_job08

      Hello,

       

      I'm currently working on creating a facility whereby users select which columns on a given ADG should be shown. I'm currently pulling all of the underlying columns into Flex but wish to provide extra functionality for the end-user to select only the columns of interest to them.

       

      Does anyone have any links/code samples for this before I try to re-invent the wheel?

       

      Thanks everyone!

        • 1. Re: Flex 3 - configurable column selection for AdvancedDataGrid
          Matt Le Fevre Level 4

          odd_job08 wrote:

           

          Hello,

           

          I'm currently working on creating a facility whereby users select which columns on a given ADG should be shown. I'm currently pulling all of the underlying columns into Flex but wish to provide extra functionality for the end-user to select only the columns of interest to them.

           

          Does anyone have any links/code samples for this before I try to re-invent the wheel?

           

          Thanks everyone!

           

          are columns generated dynamically, or are they pre-defined and then fed data?

           

          are you using a custom itemRenderer?

          • 2. Re: Flex 3 - configurable column selection for AdvancedDataGrid
            odd_job08 Level 1

            Hello,

             

            The columns would already be defined in the dataset, it's just a case of the user selecting the columns via some sort of drop down menu/radio button list. I'm not using a custom itemRenderer at present.

            • 3. Re: Flex 3 - configurable column selection for AdvancedDataGrid
              Matt Le Fevre Level 4

              if they are pre-defined, could you not simply bind the visible attribute to a boolean variable like such

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                  
                  <mx:Script>
                      <![CDATA[
                          
                          [Bindable]
                          public var col1:Boolean = true;
                          [Bindable]
                          public var col2:Boolean = true;
                          [Bindable]
                          public var col3:Boolean = true;
                          
                      ]]>
                  </mx:Script>
                  
                  <mx:CheckBox change="col1 == true ? col1 = false : col1 = true " x="193" y="200" label="column 1?"/>
                  <mx:CheckBox change="col2 == true ? col2 = false : col2 = true " x="193" y="230" label="column 2?"/>
                  <mx:CheckBox change="col3 == true ? col3 = false : col3 = true " x="193" y="260" label="column 3?"/>
                  <mx:DataGrid x="164" y="286">
                      <mx:columns>
                          <mx:DataGridColumn headerText="Column 1" dataField="col1" visible="{col1}"/>
                          <mx:DataGridColumn headerText="Column 2" dataField="col2" visible="{col2}"/>
                          <mx:DataGridColumn headerText="Column 3" dataField="col3" visible="{col3}"/>
                      </mx:columns>
                  </mx:DataGrid>
                  
              </mx:Application>
              
              
              • 4. Re: Flex 3 - configurable column selection for AdvancedDataGrid
                odd_job08 Level 1

                Thanks, this looks great. I was looking for a simple base from which to work from.