Hi,
It's been a while since I've touched as2. Apparently I couldn't get things to work without hacks.
Normally you should've be able to get away with dg.dispatchEvent({type:"headerRelease"}), but no, that didn't seem to work. I've used the Debug > List Objects option to get the name of a column header, then called the onRelease() function on it. Apparently that worked only in an onEnterFrame, which I later deleted.
Here's my code, built with help from the documentation:
//hacky boolean to check if what we asked for was done
var selfClicked:Boolean = false;
myDP = new Array({name:"Chris", price:"Priceless"},{name:"Daisy", price:"Adequate"}, {name:"Nigel", price:"Cheap"});
dg.dataProvider = myDP;
onEnterFrame = function(){
if(!selfClicked){
//ask nicely
dg.dispatchEvent({type:"headerRelease"});
//no ? oh well...
dg.content_mc.header_mc.hO0.onRelease();
//fix for header label
dg.content_mc.header_mc.fHeaderCell0._y = dg.content_mc.header_mc.fHeaderCell1._y;
selfClicked = true;
delete onEnterFrame;
}
}
this.headerRelease = function(eventObject){
//nicely hidden debugging gem here, thanks Jen deHaan!
trace(mx.data.binding.ObjectDumper.toString(eventObject));
}
dg.addEventListener("headerRelease", this);
HTH,
George