In that case, perhaps you could set sortableColumns to "false" and perform your sorting logic in some other event listener...
On Wed, Dec 10, 2014 at 12:27 PM, Deepak MS <[email protected]> wrote: > Here's what I'm trying(sample application): > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" > minWidth="955" minHeight="600" > > > <mx:Script> > <![CDATA[ > import mx.utils.ObjectUtil; > public function > sortStringFunction(totalFieldName:String,totalValue:String, > fieldName:String, isNumeric:Boolean = false):Function{ > > return function(obj1:Object, obj2:Object):int > { > if(obj1[totalFieldName] == totalValue){ > > > return 0; > > }else if(obj2[totalFieldName] == totalValue){ > > > return 0; > > }else{ > > if(isNumeric) > { > return > ObjectUtil.numericCompare(obj1[fieldName],obj2[fieldName]); > }else > { > return > ObjectUtil.stringCompare(obj1[fieldName],obj2[fieldName],true); > } > > } > > } > } > ]]> > </mx:Script> > > <mx:ArrayCollection id="ac"> > <mx:Object ischecked="true" color="" name="ABC"/> > <mx:Object ischecked="true" color="" name="KJHD"/> > <mx:Object ischecked="true" color="" name="ADFDGG"/> > <mx:Object ischecked="true" color="" name="SDF"/> > <mx:Object ischecked="true" color="" name="TRF"/> > <mx:Object ischecked="true" color="" name="DF"/> > <mx:Object ischecked="true" color="" name="YTU"/> > <mx:Object ischecked="true" color="" name="Total"/> > </mx:ArrayCollection> > <mx:DataGrid dataProvider="{ac}" width="500" height="500" > sortableColumns="true"> > <mx:columns> > <mx:DataGridColumn sortable="true" > sortCompareFunction="{sortStringFunction('name','Total','name')}"> > <mx:headerRenderer> > <mx:Component> > <mx:VBox paddingLeft="5" verticalAlign="middle" > horizontalAlign="left"> > <mx:Script> > <![CDATA[ > import mx.controls.Alert; > import mx.events.DataGridEvent; > > protected function > checkbox2_changeHandler(event:Event):void > { > > /* event.preventDefault(); > event.stopImmediatePropagation(); > */ // this doesn't avoid sorting. I want to avoid default sorting here > > for each(var item:Object in > outerDocument.ac) > { > item['ischecked'] = > event.currentTarget.selected; > } > > outerDocument.ac.refresh(); > } > > > ]]> > </mx:Script> > > <mx:HBox> > <mx:Button width="15" height="15"/> > <mx:Label text="ATCs" /> > </mx:HBox> > <mx:CheckBox > change="checkbox2_changeHandler(event)" label="Check All" /> > </mx:VBox> > > </mx:Component> > </mx:headerRenderer> > > <mx:itemRenderer> > <mx:Component> > > <mx:CheckBox selected="{data.ischecked}" label="{ > data.name}"> > > </mx:CheckBox> > > </mx:Component> > </mx:itemRenderer> > </mx:DataGridColumn> > </mx:columns> > </mx:DataGrid> > </mx:Application> > > > On Wed, Dec 10, 2014 at 3:24 PM, Deepak MS <[email protected]> > wrote: > > > Yes, I did. On click of header button, I called those 2 methods but it > > still sorts the column data. > > > > On Wed, Dec 10, 2014 at 3:15 PM, Evyatar Ben Halevi-Arbib < > > [email protected]> wrote: > > > >> Have you tried using the following calls in your renderer's event > handler > >> function? > >> event.preventDefault(); > >> event.stopImmediatePropagation() > >> > >> Regards, > >> Evyatar > >> > >> On Wed, Dec 10, 2014 at 11:30 AM, Deepak MS <[email protected]> > >> wrote: > >> > >> > Hey guys, > >> > I have a Datagrid with first column being a custom itemrenderer with a > >> > check box, a box(to display color) and then a label. > >> > > >> > I am using headererRenderer too for that column, but with a check box > >> and a > >> > button. The header's check box is used to check\uncheck all items in > the > >> > datagrid. > >> > > >> > When I click on headererenderer's button or checkbox, the data is > >> getting > >> > sorted in the grid. I don't want to do sort when I click on any item > in > >> > headerenderer, I want to sort it only when user clicks on header apart > >> from > >> > that button and checkbox. > >> > > >> > I tried to stop event propogation, but always header release event is > >> > triggered first than headerrenderer's button or check box click. So > stop > >> > propagation wont work. > >> > > >> > Is there anyway to avoid sorting on click of headerrenderer item? I'm > >> using > >> > Flex 3.6. > >> > > >> > Cheers! > >> > > >> > > > > >
