How to dynamically add a column to the DataGrid

Hey there everyone. Forgive me, I'm very new to this.
I use a data grid to display values analyzed in an xml file.
The application needs of 5 columns, no problem, however, if a value is present in the xml file, I need to add another column.
If I have a var defined as
var gps_present which is a string, and if the value == 'Yes' adds a column in my datagrid?

< mx:DataGrid id = "summary_grid" x = "10" y = "15" width = "500" height = "434".
dataProvider = "{summary.lastResult.phones.phone}" >
< mx:columns >
< mx:DataGridColumn headerText = "phone number" dataField = "phone number" width = "3" / >
< mx:DataGridColumn headerText = "inc_java" dataField = "inc_java" width = "3" / >
< mx:DataGridColumn headerText = "inc_sms" dataField = "inc_sms" width = "3" / >
a logic here if inc_gps == 'y '.
< mx:DataGridColumn headerText = "inc_gps" dataField = "gps" width = "3" / >
< / mx:columns >
< / mx:DataGrid >


Thank you for any advice on that.

nephish,

Yes. Sorry, displaying large blocks of code on the forums is a little tricky. Posted an example here: http://blog.flexexamples.com/2008/03/04/dynamically-adding-new-columns-to-a-datagrid-contr ol in flex /

Hope that helps,
Peter

Tags: Flex

Similar Questions

  • How to dynamically add an Option in the drop-down list?

    I have this code:

    {Drop-down list

    ID: list

    Title: 'list '.

    onCreationCompleted: {}

    opion var = new Option();

    opion. Text = "Hello";
    opion. Value = 4;

    List.Add (opion);

    }

    }

    After the launch of the application, the list is empty.

    Why my code does not work?

    It is easy to dynamically add options

    first add this to your attachedObjects:

    ComponentDefinition {
                id: optionDefinition
                Option {
                }
            }
    

    then do something like this

    var newOption = optionDefinition.createObject()
                newOption.text = ...
                newOption.value = ...
                newOption.description = ...
                newOption.selected = ....
                yourDropDown.add(newOption)
    
  • How to dynamically add columns to the table

    Hi all

    I'm new to ADF and need help on sub condition.

    We have created a ViewObject on the EMPLOYEE table that has under columns:

    EMP_ID,

    EMP_NAME,

    DEPARTMENT,

    COST_CENTER,

    BUSINESS_UNIT

    COUNTRY

    GCODE

    We need to create a page in the ADF with employee table to show only below the columns

    EMP_ID,

    EMP_NAME,

    DEPARTMENT,

    COST_CENTER

    Later, if necessary user should be able to add other columns to the page dynamically.

    Can you please advice on how to implement this feature.

    Thank you.

    Kind regards

    Vidya

    Hello.

    There could be a simple solution, which is to use the component PanelCollection.

    Drag ' drop your VO to a page and create a Table with all the attributes.

    For columns that emp_id, emp_name, cost_center, set the Visible property to false.

    Put the PanelCollection component on your page and drag your table inside.

    When you run the page you will see the view menu in the upper left corner of the table above. You can show/hide columns in this menu.

  • How to add a column at the end of the table of the already designed the document... ?

    Hello

    I am writing a javascript to add a column at the end of the table in the Indesign document. using our plug-in, we have created the Indesign document.

    Each table I want to add an extra column at the end. Is it possible... ? Please help me if anyone has the idea in this regard.

    Thank you

    Vimala L

    Hi Vimala,

    Please try the JS code below, copy the following code will add the new column in each table last column after.

    var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    
    for(i=0; i
    

    THX,

    csm_phil

  • How can I add a device of the anther

    How can I add a device of the anther

    Hello

    "If you paired with your Apple Watch but who want to use it with another iPhone, you can transfer your Apple Watch and its contents to your new iPhone.

    Instructions here > set up your Apple Watch

  • How can I add a column with my favorites for my screen?

    I just started using Firefox now and can not find a way to add a column on the left side of my window in Firefox (which I didn't in Internet Explorer) showing all the links to my favorite site. In which case it is important, I use Window XP as my operating system).

    To show your Firefox Bookmarks Sidebar ("Favorites" are in IE, not Firefox), use CTRL + B to open or close the sidebar. If the bookmarks bar is open when you exit Firefox (Firefox button > exit or file > exit), it should be open when you restart Firefox.

    • You can also use the following to open or close the bookmarks bar

      • Press ALT or F10 to temporarily show the Menu bar, click View > sidebar > bookmarks to check/uncheck it (checked = displayed; United Nations-checked = not displayed
      • Hold down the ALT key while pressing the VEB keyboard letters

    If this answer solved your problem, please click 'Solved It' next to this response when connected to the forum.

    Not related to your question, but...

    You may need to update some plug-ins. Check your plug-ins and update if necessary:

  • How can I add a Word to the lexicon? that is, how to stop my e-mail name AutoCorrect?

    How can I add a Word to the lexicon? that is, how to stop my e-mail name AutoCorrect?

    Greetings bonbog,

    You can add words to the spelling on your Mac dictionary. See this help page - check spelling and Grammar - Help Mac

    Specifically -.

    • Add words to the spelling dictionary: Control-click on a Word, then choose memorize spelling. The Word will not be marked as spelled in any document. To have the word marked as wrong spelled once again, the control key in a document, then choose unlearn spelling.

    Thank you for using communities of Apple Support.

    Be well.

  • How can I add my laptop to the network and connect to the internet as well

    I have internet access on my computer at home, the ipod, the ipad and iphone.  How can I add my laptop to the network and connect to the internet as well?

    Hello

    I suggest you to refer to the following Microsoft article and check if it helps.

    Add a device or computer to a network:

    http://Windows.Microsoft.com/en-us/Windows-Vista/add-a-device-or-computer-to-a-network

    For more information, see the following Microsoft article.

    http://Windows.Microsoft.com/en-us/Windows-Vista/setting-up-a-home-network

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-you-need-to-set-up-a-home-network

    http://Windows.Microsoft.com/en-us/Windows/explore/home-networking

    Hope the information is useful.

  • How can I add a destination to the send menu to?

    How can I add a destination to the send menu to?

    Put a shortcut to the destination in the C:\Users\\AppData\Roaming\Microsoft\Windows\SendTo folder.

  • How can I add a program to the start selective msconfig and how to delete a startup item?

    How can I add a program to the start selective msconfig and how to delete a startup item? Once, I knew but forgot.

    Remove items not controlled in MSConfig
    http://www.PCWorld.com/article/255514/remove_unchecked_items_from_msconfig.html

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/default.aspx/KB/929135

  • can I have a tile in windows 8 for facebook and twitter? Also, how can I add a device in the devices on the right side?

    I would like to a tile on the homescreen of Facebook and Twitter (I don't see an APP for either).  I can do this and if so, how?

    How can I add a device to the peripheral icon on the right side?

    Dear NelliBli46,
    Welcome to the Microsoft community!

    Question 1: For Facebook and Twitter tile question.

    You can get your Facebook account and Twitter RSS directly on your screen to start using applications Photos and people.
    These links help you to configure the applications.
    For the Photos App:
    http://Windows.Microsoft.com/en-us/Windows-8/photos-app-FAQ
    For the purposes of people:
    http://Windows.Microsoft.com/en-us/Windows-8/people-FAQ
     

    Question 2: To add a device to the peripheral icon.

    You can use this link to add devices to your computer
    http://Windows.Microsoft.com/en-us/Windows-8/Add-device-or-PC-to-network

    Once you add a device, under devices in the charms bar you will see what options or devices are available according to the open app or window.

    If you still have questions, feel free to contact us.
  • Add a column to the Section

    Hi, I would do the following:

    In a specification of Prodcut-> tab related specifications, I would like to add a column on the section of the Alternative standards.  Currently, the section shows # Spec and Spec - I want to add a column for the classification.

    I looked through some of the extensibility documentation, but didn't notice anything to do something like that (it's probably there somewhere and I just lack).  Can you please give me an example or point me in the right direction on this?

    Thank you

    Hi Mike,.

    We currently have is not an extension of available column add new columns to this section. Feel free to save a value for this application.

    However, you can add the collation of the column name of the technique, if you wish. To do this, you must create an extension of FormatPlugin by using the AltGlobalStandardIdentityPlugin extension point. Your plugin would return the classification (and if you want that the State continue to be displayed, which also include).

    See the PluginExtensions in the ExtensibilityPack in the ReferenceImplementations\PluginExtensions\Documentation folder and read the hardware section identity Plugins and the section called create and deploy a new Format Plugin. This will also guide a simple reference implementation. You can also see the complete source code in the ReferenceImplementations\PluginExtensions\SourceCode\ReferencePlugins\ folder. This Visual Studio contains example FormatPlugins for you to review.

    You will need determine if the classification should also appear on the printing specifications. If Yes, then this is just additional method (and interface) to implement, but documentation shows that.

    Kind regards

    Ron

  • How can I add a comment to the document

    How can I add a comment to the document

    Hi djtbull,

    Please see the following KB doc to learn more about the same:

    Acrobat help. Commenting in the PDF files

    Kind regards

    Ana Maria

  • How can I add a widget for the dashboard widget in Muse

    How can I add a widget for the dashboard widget in Muse? Please include steps.

    Only of the native widgets Muse go to the widgets Panel. For your own or 3rd party widgets are stored in your library panel. If you save your own just right click the element or widget on your page of muse. In options, select Save in the library.

  • How can I add a link using the adobe reader software?

    How can I add a link using the adobe reader software?

    Hi johnny05,

    This isn't something you can do with Adobe Reader. To edit a PDF file, including adding a link, you must use Acrobat. We invite you to try Acrobat DC for 30 days; You can download a trial of this page: Download Adobe Acrobat free trial version | Acrobat Pro DC.

    Best,

    Sara

Maybe you are looking for