Sort DataGrid by column after save (AS3/spark)
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Sort DataGrid by column after save (AS3/spark)

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    2

    Sort DataGrid by column after save (AS3/spark)

    I have a spark DataGrid, where the user can sort the row by clicking the column headers... as expected. When they double click a row, it go to an edit. After clicking the save (or back button
    [not the browser back button]) the are returned to the updated datagrid. I want to retain the sorting they had before the edit. Here is code I have to capture the sort column.

    Code:
    protected function onSortChange(event:GridSortEvent):void
    				
    	{
    		app.sortColumnIndices = event.columnIndices;
    		app.sortColumnName = event.newSortFields[0].name;
    	}
    This does get the column name and columnIndices as expect. When the screen refreshes with the DataGrid, I have the follow code, which is being executed:

    Code:
    				if (app.sortColumnIndices){
    					
    					dg.sortByColumns(app.sortColumnIndices);
    					var sortColumnName:SortField = new SortField(app.sortColumnName,true);
    					sortColumnName.setStyle("locale","en-US");
    					
    					sort.fields = [sortColumnName];
    					
    					entitiesDP.sort = sort;
    					entitiesDP.refresh();
    				}	
    
    				dg.dataProvider = entitiesDP;
    The app.sortColumnIndices and app.sortColumnName both contain the "previous" values that I want to use in the sort.

    The problem is the DataGrid displays in the original, unsort order..... HELP! PLEASE!

    Thanks-

  2. #2
    Member
    Join Date
    Aug 2012
    Posts
    55
    add stage.invalidate(); to the stage - that might work

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Rachelg,

    Thanks for the reply. Sorry, I didn't get notified of your post reply. I am not following what you mean "add to stage"? I am working in FLEX, not Flash. Thanks

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    665
    maybe you need dg.sortByColumns(app.sortColumnIndices, true); I really have little idea, but I think having "true" there in editable grid makes it automatically resort itself when data changes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com