views:

935

answers:

2

In Flex I'm using the following code to allow sorting in a DataGrid (the data is paged and sorted serverside).


        private function headerReleaseHandler(event:DataGridEvent):void
        {
            var column:DataGridColumn = DataGridColumn(event.currentTarget.columns[event.columnIndex]);

            if(this.count>0)
            {
                if(this.query.SortField == column.dataField)
                {
                    this.query.SortAscending = !this.query.SortAscending;
                }
                else
                {
                    this.query.SortField = column.dataField;
                    this.query.SortAscending = true;
                }
                this.fill();
            }

            event.preventDefault();
        }

This works perfectly, except that the arrows that indicate sorting isn't shown. How can I accomplish that?

Thanks! /Niels

+4  A: 

There is an example here if this is what you are looking for: http://blog.flexexamples.com/2008/02/28/displaying-the-sort-arrow-in-a-flex-datagrid-control-without-having-to-click-a-column/

It looks like you need to refresh the collection used by your dataprovider.

shadenite
A: 

in the above code what does "this" refer to is it the datagrid because I am confused by this.query.SortField , I am assuming 'this' and "query' are your own custom objects. and why are you checking for count. what count is that.

Regards -Mohan

I've extended DataGrid.
Niels Bosma