When someone clicks the header, a HEADER_RELEASE event is dispatched, and if you call preventDefault() on the event, the sort will not take place. You should then go get the data. You can freeze the screen by putting up a modal popup or some other UI.
Once the data is returned, store the name of the sort and use that in your renderers to show the underline. You would match against that name instead of owner.dataprovider.sort.sortField[0].name. Check the forum archives and search the internet. Someone has successfully overridden the actual Sort so sortarrows would continue to work but the underlying collection would not be sorted. -Alex From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of cjcuccaro Sent: Tuesday, September 16, 2008 6:17 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Trying to underline datagrid header text. How??? No there isn't a sort applied. I want to override the default sorting functionality so the data can be sorted on the server. Sorry I wasn't clear enough on one of my earlier posts. The sorting is done on the server to a much larger set of data than what is displayed in the Flex app. When I call the service and get the result, which is a subset of the overall result set, it is already sorted for display. Hmmm, is there a way to not override the default functionality but to just freeze the screen until the new sorted data is returned from the server to be displayed? If I can freeze the datagrid so the sorting on the flex side isn't seen and then unfreeze it when the new data arrives might work. Or... Can I override the default sort to prevent a "normal" sort just so the sort arrow remains? As you can tell I'm just grasping for any work around at this time. Thanks, CJ --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, Alex Harui <[EMAIL PROTECTED]> wrote: > > That looks ok. Is there really a sort applied to the collection/dataprovider or did you just happen to return the server results sorted in some way? > > From: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>] On Behalf Of cjcuccaro > Sent: Monday, September 15, 2008 5:30 AM > To: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> > Subject: [flexcoders] Re: Trying to underline datagrid header text. How??? > > > This is my check I put in the set data, sortEventHandler, and clickHandler events within the renderer: > > if(DataGrid(listData.owner).dataProvider.sort != null){ > var sortVal:String = DataGrid (listData.owner).dataProvider.sort.sortField[0].name; > } > > I put a break on the variable assignment within the if block and it doesn't stop within the block. > > Am I looking at the correct collection? > > Thanks, > CJ > > --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, Alex > Harui <aharui@> wrote: > > > > Making changes in set data() makes you data-driven. Changing when events fire makes you event-driven. > > > > Maybe you're looking at the wrong collection? What does the code that checks the sortField look like? > > > > From: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> [mailto:flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>] On Behalf Of cjcuccaro > > Sent: Sunday, September 14, 2008 6:28 AM > > To: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> > > Subject: [flexcoders] Re: Trying to underline datagrid header text. How??? > > > > > > Hmmm. Thought I was data-driven. I did attempt to check the sortField > > but it was always null. I put checks in the sortEventHandler and the > > clickHandler to see when the sort would change to not null but it > > remained null. > > > > So when you say the header gets recycled it calls the set data > > method? Sh! ould I be making the changes in the set data method at this > > point? > > > > I feel like I'm wrestling an alligator and going 'round and 'round > > and doing nothing but getting tired. phew! > > > > Thank you again for your help Alex. > > Regards, > > CJ > > > > --- In > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com>, Alex Harui aharui@ wrote: > > > > > > See my reply from today. You need to be data-driven. I still > > think getting the collection's Sort and comparing the sortField > > against the column's dataField is the right plan. > > > > > > From: > > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com> > > [mailto:flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com>] On Behalf Of cjcuccaro > > > Sent: Saturday, September 13, 2008 6:31 PM > > > To: [EMAIL PROTECTED] ups.com<mailto:flexcoders% 40yahoogroups.com>> & gt; Subject: [flexcoders] Re: Trying to underline datagrid header text. > > How??? > > > > > > > > > Well thought I had it licked but not! > > > > > > It works great until I make my HTTPService call to the Spring > > > controller on the server to get the sorted result. Just like the > > sort > > > arrow the underlining disappears after the service call. > > > > > > I only show 20 records out of a much larger result set so when > > > sorting I need to call the HTTPservice again to get the sorted > > subset > > > after the entire resultset is sorted on the server. ERRRR! > > > > > > Does anyone have a work around for this kind of behavior? What do I > > > need to extend/override to keep the sort arrow or in my latest > > > attempt the underlining? > > > > > > Any and all help is appreciated. > > > > > > Desperately, > > > CJ> > > > > --- In > > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com><mailto:flexcoders% > > 40yahoogroups.com>, "cjcuccaro" <cj_cuccaro@> wrote: > > > > > > > > I believe I got it. I use the added sortEventHandler event > > listener > > > > to set the style textDecoration to none and the clickHandler to > > > reset > > > > the textDecoration to underline. > > > > > > > > private function sortEventHandler > > > > (event:DataGridEvent):void > > > > { > > > > if (event.itemRenderer == this){ > > > > event.preventDefault(); > > > > } > > > > setStyle("textDecoration", "none"); > > > > } > > > > > > > > private function clickHandler(event:MouseEvent):void > > > > { > > > > setStyle("textDecoration", "unde! rline"); > > > > } > > > > > > &g! t; >< BR>> > > and it took me way to many hours to come to this conclusion. > > yikes! > > > > > > > > Thanks for your input Alex, it is greatly appreciated. > > > > > > > > Regards, > > > > CJ > > > > > > > > --- In > > > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com><mailto:flexcoders% > > 40yahoogroups.com>, Alex Harui <aharui@> wrote: > > > > > > > > > > I would probably test that the DataGrid > > > > (listData.owner).collection.sort.sortFIeld[0].name == > > data.dataField > > > > > > > > > > You'll need more null checks and what not but that tests to see > > > if > > > > the sort on the collection is sorting on the same field as the > > > column > > > > the header renderer is displaying. > > > > > > > > > &! gt; From: > > > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com><mailto:flexcoders% > > 40yahoogroups.com> > > > > [mailto:flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com><mailto:flexcoders% > > 40yahoogroups.com>] On Behalf Of cjcuccaro > > > > > Sent: Friday, September 12, 2008 8:27 PM > > > > > To: > > > > > flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com><mailto:flexcoders% 40yahoogroups.com><mailto:flexcoders% > > 40yahoogroups.com> > > > > > Subject: [flexcoders] Re: Trying to underline datagrid header > > > text. > > > > How??? > > > > > > > > > > > > > > > Thank you Alex for your feedback. > > > > > > > > > > So I visited your blog read about renderers, very good info, and > > > > started with your checkbox example. I changed! the checkbox to a > > > label > > > > and ha! ve it un derlining on the click but don't know how to toggle > > > the > > > > underline when clicking other columns. Can you or anyone provide > > > any > > > > suggestions on how I can achieve this? Below is the headerRenderer > > > > custom class. > > > > > > > > > > RgColHeaderLabel.as file: > > > > > > > > > > package > > > > > { > > > > > import mx.controls.Label; > > > > > > > > > > public class RgColHeaderLabel extends Label > > > > > { > > > > > > > > > > import flash.events.MouseEvent; > > > > > import mx.events.DataGridEvent; > > > > > import mx.controls.DataGrid; > > > > > import mx.controls.dataGridClasses.DataGridColumn; > > > > > import mx.controls.dataGridClasses.DataGridListData; > ! > > > > > > > > > private var _data:DataGridColumn; > > > > > > > > > > public function RgColHeaderLabel() > > > > > { > > > > > super(); > > > > > addEventListener("click", clickHandler); > > > > > } > > > > > > > > > > override public function get data():Object > > > > > { > > > > > return _data; > > > > > } > > > > > > > > > > override public function set data(value:Object):void > > > > > { > > > > > _data = value as DataGridColumn; > > > > > > > > > > text = DataGridListData(listData).label ; > > > > > setStyle("textAlign","center"); > > > > > DataGrid(listData.owner).addEventListener > > > > (DataGridEvent.HEADER_RELEASE, sortEventHa! ndler); > > > > > > > > > > }> & gt; > > > > > > > private function sortEventHandler(event:DataGridEvent):void { > > > > > if (event.itemRenderer == this) > > > > > event.preventDefault(); > > > > > } > > > > > > > > > > private function clickHandler(event:MouseEvent):void > > > > > { > > > > > //how do i underline only the clicked header? > > > > > > > > > > setStyle("textDecoration", "underline"); > > > > > } > > > > > > > > > > } > > > > > } > > > > > > > > > > Below is your dg.mxml with a modification to the headerRenderer: > > > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > > > > xmlns:local="*" >> > > > > > > > > <mx:Script> > > > > > <![CDATA[ > > > > > > > > > > private var dp:Array = [ > > > > > { symbol: "ADBE", name: "Adobe Systems Inc.", > > > > > news: "Adobe Flex is <b>great</b>! according to > > > > <i>FlexCoders</i>" }, > > > > > { symbol: "MACR", name: "Macromedia Inc.", > > > > > news: "<FONT color='#FF0000'>Macromedia</FONT> is absorbed into > > > > Adobe" }, > > > > > { symbol: "MSFT", name: "Microsoft Corp.", > > > > > news: "Microsoft sees <FONT size='20'>Flex</FONT> for the first > > > > time" }, > > > > > { symbol: "IBM", name: "IBM Corp.", > > > > > news: "IBM was once the top <b><i>dog</i></b> but no more" } > > > > > ]; > > > > > > > >! > > ]]> > > > > > </mx:Script>> &g t; > > > > > > > <mx:DataGrid id="dg1" initialize="dg1.dataProvider = dp" > > > > paddingTop="0" paddingBottom="0" verticalAlign="middle" > > > > > variableRowHeight="true" > > > > > > <mx:columns> > > > > > <mx:DataGridColumn headerText="Name" dataField="name" > > width="140" > > > > headerRenderer="RgColHeaderLabel"/> > > > > > <mx:DataGridColumn headerText="Symbol" dataField="symbol" > > > > width="60" headerRenderer="RgColHeaderLabel"/> > > > > > <mx:DataGridColumn headerText="News" dataField="news" > > > > wordWrap="true" width="200" headerRenderer="RgColHeaderLabel"/> > > > > > </mx:columns> > > > > > </mx:DataGrid> > > > > > > > > > > </mx:Application> > > > > >> > > > > > > > > > > > > > Thanks, > > > > > > > > > > CJ > > > > > > > > > > > > > > >