Skip navigation
Currently Being Moderated

datagrid not rendering after dataprovider update

Jun 28, 2012 10:48 AM

Hallo.. I have a datagrid and an AsyncListView object as dataProvider cause i am doing paging... When i add element to the dataprovider everything works good in main window but not in new NativeWindow ... the problem is that the list does not refresh correctly when adding new elements only in Native Window.. How can i force the updateDisplayList on Datagrid to make it redraw everything??.. i tried:

 

datagrid .invalidateSkinState();

datagrid .invalidateDisplayList();

datagrid .validateNow();

 

They do not work... Pls help

 

Max

 
Replies
  • Currently Being Moderated
    Sep 5, 2012 7:43 AM   in reply to Maximist

    Having a similar problem here.  Pulling MySQL data into a datagrid and then allowing the user to update a record by moving datagrid fields from a particular row to textinput fields whenever they click on a row like this:

     

    protected function dgData_itemClickHandler(event:ListEvent):void

                {

                    txtName.text      = event.itemRenderer.data.name;....

     

    Once they modify the data in the textinput fields and click the Update button, the MySQL database is being updated properly for that record, but I want to reflect the change in the corresponding row of the datagrid.

     

    From what I read, invalidateDisplayList was supposed to do the job, but it's not happening.

     

    Any other ideas are appreciated.

     

    Thanks,

     

    Gary

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 11:43 AM   in reply to GaryDJ

    Are you updating the data objects in the dataprovider as well?  That should cause collectionChange events and cause the DG to update.  Calling invalidateDisplayList should not be necessary in most cases.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 4:29 PM   in reply to Flex harUI

    For the datagrid dgData, I'm executing:

     

    dgData.dataProvider.refresh();

     

    but the only effect that seems to have is to re-sort the datagrid, yet the row I just updated still has the old data in it, even though I've confirmed that the database was updated before this was executed.

     

    Thanks,

     

    Gary

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 8:43 PM   in reply to GaryDJ

    I’m unclear how many pieces there are.  Usually there is a server-based database, then a dataprovider full of records from that database.  The records/items from the dataprovider are assigned to the data property in a renderer.  When you update a record, you have to update both the server-based database and the record in the dataprovider.

     

    In general, calling refresh() is not required.  If you have records that dispatch change events, it should just work, otherwise you might need to call itemUpdated on the dataprovider.

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 9:21 PM   in reply to Flex harUI

    >> you have to update both the server-based database and the record in the dataprovider

     

    Ok, this may open something up.

     

    When the user clicks on the datagrid, I move each field from the datagrid to text fields for editing like this:

     

    protected function dgData_itemClickHandler(event:ListEvent):void

    {

         txtName.text      = event.itemRenderer.data.name;

     

    so are you saying that I need to find a way to manually move the edited name back to the itemRenderer field in the datagrid even though I've already updated the MySQL database successfully?  If I can figure out the syntax to do that, then I don't mind going that route, I just don't know how to refer back to the selected row of the grid since now that function wouldn't be triggered by a click event on the grid, but instead on a button release.

     

    Really appreciate your helpful responses,

     

    Gary

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 5, 2012 10:40 PM   in reply to GaryDJ

    Normally, folks work off the “change” event on the datagrid, which means that the selectedItem is set.  Folks usually fill out the UI from the selected item, let folks edit it, then set the fields on the selectedItem and call itemUpdated if you need to.

     

    Sometimes folks then take the selectedItem and send it back to the server.  Other times, folks update the server and then an update comes back from the server and updates the dataProvider.

     

    -Alex

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2012 9:38 AM   in reply to Flex harUI

    Ok we're getting close.

     

    >>Normally, folks work off the “change” event on the datagrid, which means that the selectedItem is set.  Folks usually fill out the UI from the selected item, let folks edit it

     

    This is exactly what I'm doing -- for the itemClick event on the datagrid, I call the clickhandler in the message above, which moves the fields from the selectedItem to the form fields.

     

    The MySQL update to the sever is also working.   My only remaining problem is in moving the fields back to the selectedItem in the datagrid so the user can see that their update worked.  Before the user edits the data, within the click handler, I was able to refer to these fields as

     

    event.itemRenderer.data.name;

     

    That event refers to the user clicking on row of the datagrid.  After the fields are edited though, user is clicking the update button and so I can't refer to the edited row in the datagrid by "event.itemRenderer...." where I want to move the updated data back into the grid.

     

    I've tried (unsuccessfully) to save a reference to this row, but haven't figured out how to do that.

     

    Can you tell me how to refer back to this so I can say the equivelent of

    selected.datagridrow.address = form.address.text and know which row to update even though the row was not just clicked (only was clicked before the user did the edits in the form).

     

    Thanks again, Alex.

     

    Gary

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2012 12:19 PM   in reply to GaryDJ

    Unless something has been selected, it should be dg.selectedItem.datagridrow.address

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 8, 2012 6:51 PM   in reply to Flex harUI

    I wasn't able to get selecteditem.datagridrow to point where I needed it, but it got me on the right track.  This is what worked:

     

    dataArray.setItemAt({address:txtAddress.text},dgData.selectedIndex);

     

    I would never have found it, though, without all the help here.

     

    Thanks again,

     

    Gary

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points