Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 489621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:49:36+00:00 2026-05-13T01:49:36+00:00

Does anybody know how to add a new row to a datagrid via a

  • 0

Does anybody know how to add a new row to a datagrid via a checkbox.

example:

  checkbox 1 : label (PS2)
  checkbox 2 : label (PS3)
  checkbox 3 : label (PSP)

By selecting one or all of these checkboxes i what to add a new Datagrid row.

  Datagrid

  Console           price
  row1 PS2           $20,
  row2 PS3           $30,
  row3 PSP           $15,

i hope this example is clear enough
thanks

DJ

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:49:36+00:00Added an answer on May 13, 2026 at 1:49 am

    Add an item to the dataProvider of the DataGrid from the change event handler of the CheckBox – make sure you check for existing items (and remove them when check box is unchecked) to avoid duplicates. If you can post the code of DataGrid, we might be able to give a sample code showing how to do this.

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
        creationComplete="create()">
        <mx:DataGrid id="dg" dataProvider="{dp}">
          <mx:columns>
            <mx:DataGridColumn dataField="console"/>
            <mx:DataGridColumn dataField="price"/>
          </mx:columns>
        </mx:DataGrid>
        <mx:CheckBox id="cb1" change="onCheck(event)"/>
        <mx:CheckBox id="cb2" change="onCheck(event)"/>
        <mx:CheckBox id="cb3" change="onCheck(event)"/>
        <mx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                private var prices:Array = ["$20", "$30", "$15"];
                private var labels:Array = ["PS1", "PS2", "PS3"];
                private var checkBoxes:Array;
                [Bindable]public var dp:ArrayCollection;
                private function create():void
                {
                    checkBoxes = [cb1, cb2, cb3];
                    for(var i:Number = 0; i < labels.length; i++)
                        CheckBox(checkBoxes[i]).label = labels[i];
                    dp = new ArrayCollection([]);
                }
                private function onCheck(event:Event):void
                {
                    var cb:CheckBox = CheckBox(event.currentTarget);
                    var index:Number = indexOf(cb.label);
                    if(cb.selected && index == -1)
                        dp.addItem({console:cb.label, 
                            price:prices[labels.indexOf(cb.label)]});
                    else if(!cb.selected && index != -1)
                        dp.removeItemAt(index);
                }
                private function indexOf(str:String):Number
                {
                    for(var i:Number = 0; i < dp.length; i++)
                    {
                        var item:Object = dp.getItemAt(i);
                        if(item.console == str)
                            return i;
                    }
                    return -1;
                }
            ]]>
        </mx:Script>
    </mx:Application>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anybody know a good and free add-in for Visual Studio 2005 to get
Does anybody know any good resources for learning how to program CIL with in-depth
Does anybody know a technique to discover memory leaks caused by smart pointers? I
Does anybody know of any sample databases I could download, preferably in CSV or
Does anybody know of a way to list up the loaded plugins in Vim
Does anybody know the logic behind making DataSourceSelectArguments sealed? I've implemented a custom DataSource
Does anybody know a good tutorial about Squid plug-in development?
Does anybody know of a method for creating custom Performance Counters using ordinary unmanaged
Does anybody know how to get thumbnail (still image) from 3gb video file? First
Does anybody know what hypothetical indexes are used for in sql server 2000? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.