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

  • Home
  • SEARCH
  • 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 8530073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:10:35+00:00 2026-06-11T09:10:35+00:00

I’m using mx:DataGrid and I cannot change to spark (it’s a legacy project). The

  • 0

I’m using mx:DataGrid and I cannot change to spark (it’s a legacy project). The DataGrid is editable and when the users get in the last column I want to add a new column and start the edit mode in the first column of the new row. I can do this.

My problem is that sometimes the last column cannot be edited, so I added an itemEditBeginning listener to stop the edit and add the new row. That’s my problem. When the user get in the last field, the new row is added but I cannot see it. I have to click in the column header to sort datagrid data, then the new rows appears. It’s kind of a delay.

My code is bigger, but this simple code can reproduce the same problem:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           creationComplete="application1_creationCompleteHandler(event)"
           minWidth="955" minHeight="600">
    <fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.events.CollectionEvent;
        import mx.events.CollectionEventKind;
        import mx.events.DataGridEvent;
        import mx.events.FlexEvent;

        [Bindable] public var itens:ArrayCollection;

        protected function application1_creationCompleteHandler(event:FlexEvent):void {
            itens = new ArrayCollection();
            itens.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChange);

            itens.addItem({a: '1', b: '2'});
        }

        protected function onCollectionChange(event:CollectionEvent):void {
            if (event.kind == CollectionEventKind.ADD) {
                var row:int = itens.length - 1;
                var column:int = 0;
                var args:Array = [row, column];
                callLater(moveTo, args);
            }
        }

        protected function moveTo(row:int, col:int):void    {
            itensDg.editedItemPosition = { rowIndex:row, columnIndex:col };
        }

        protected function addInfo():void {
            itens.addItem({a: '10', b: '20'});
        }

        protected function itensDg_itemEditBeginningHandler(event:DataGridEvent):void {
            if (event.columnIndex == 1) {
                event.preventDefault();
                addInfo();
            }
        }

    ]]>
    </fx:Script>

    <mx:DataGrid id="itensDg" dataProvider="{itens}" editable="true" 
             itemEditBeginning="itensDg_itemEditBeginningHandler(event)" />
</s:Application>

Any tips about how to solve this?

Thanks.

  • 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-06-11T09:10:36+00:00Added an answer on June 11, 2026 at 9:10 am

    Trish answer led me to a solution that works. DataGrid has its own itemEditBeginning listener that modifies the editedItemPosition. Firstly I tried to stop the propagation of the itemEditBeginning event, but I realized some focus and mouse events modifies the editItemPosition too. So, the item was added in the array, my onCollectionChange listener was called, but then other events modified the editedItemPosition later.

    So, instead of changing the editedItemPosition in the CollectionEvent listener, I simply changed it after adding the element:

    protected function addInfo():void {
        itens.addItem({a: '10', b: '20'});
        var row:int = itens.length - 1;
        var column:int = 0;
        var args:Array = [row, column];
        callLater(moveTo, args);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.