BTW, I also fiddled with dispatching the HEADER_RELEASE event, before I
used a custom sort, and one problem is, that its behavior depends on
whether the column to be sorted was the last sorted column or not. If it
was the previous sort column a header release event will reverse the
sort order, if it was not the last column, it will reuse the same sort
order that it had when it was last used - in some cases you may end up
dispatching the header release twice, to get the desired sort order, and
you can see... this is not a good solution ;-)


--- In [email protected], "iko_knyphausen" <[EMAIL PROTECTED]> wrote:
>
>
> I just went through the same exercise, and ended up using the
> "recommended" method, which is creating your own Sort object...
>
> The basic working is to
>
> 1. take a collection (either arraycollection or xmllistcollection) as
> dataprovider
> 2. define a Sort object for it (you do this by creating SortFields and
> putting them into the fields array of the Sort object)
> 3. execute a Refresh on your collection
>
> If you trigger your sort via HeaderRelease events, you should call
> preventDefault() in that handler so that only your sort gets executed.
>
> You can find code samples if you look in the docs (the example I used
> was about sorting multiple columns at the same time)
>
> HTH
> --- In [email protected], "Robert Chyko" rchyko@ wrote:
> >
> > One thing to look at would be dispatch a HEADER_RELEASE event on the
> > datagrid. Its not the most straightforward fix, and will take a
little
> > tweaking to get to work right, but it is doable.
> >
> >
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Adam Royle
> > Sent: Thursday, March 01, 2007 8:09 PM
> > To: [email protected]
> > Subject: [flexcoders] simulate datagrid header click, or set
> > default sort column
> >
> >
> >
> >
> > Hi guys,
> >
> > This came up last week but no working response was given.
> >
> > I have my data sorted in a dataProvider, however whenever I add
> > new data I add it to the end of the ArrayCollection. However this
> means
> > the datagrid is no longer sorted correctly.
> >
> > I wish I could execute the private method sortByColumn() that
> > exists in the DataGrid class, but it's private!!
> >
> > Anyone with a solution? I have tried subclassing and also
> > copying code directly, but the sortByColumn method uses private
> > variables, so I'm stuck again.
> >
> > Can anyone suggest a solution to my problem?
> >
> > Cheers,
> > Adam
> >
>



Reply via email to