2009-11-30 142 views
0

我正在使用一个数组来填充flash 8 datagrid,很简单。我也预先排列数组中的一个字段,也很简单。flash 8 datagrid排序箭头

我想排序箭头出现第一填充网格时,但它不是!

用户必须点击标题单元格的箭头变得可见。有什么方法可以覆盖这种行为。

感谢

回答

0

这已经有一段时间,因为我已经感动AS2。显然,我不能让事情没有黑客的工作。

通常你应该已经能够与dg.dispatchEvent脱身({类型:“headerRelease”}),但没有,似乎没有工作。我使用了Debug> List Objects选项来获取列标题的名称,然后在其上调用onRelease()函数。显然这只在一个onEnterFrame中工作,我后来删除了它。

这里是我的代码,以帮助建立从文档:

//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, 乔治

+0

乔治你好。 非常感谢,这真棒,确实强制在网格上放置箭头。 几个问题,如果我可以。 什么是派遣事件行,因为它似乎仍然工作时,它被删除。 当我在代码运行后点击第1列时,标题文本的移动方式与其它列的移动方式不同(如果难以解释,请参考参考资料!)。 无论如何非常感谢。 – Dave 2009-12-01 10:46:17

+0

嗨戴夫。通常你应该能够从组件发送一个事件并且应该修复它。你可以把它擦掉,我想表现出试图用一种不太古怪的方式去做。我明白你的意思,标题文字对角线而不是水平移动。我认为这可能是因为在按下标题之前不会创建排序箭头剪辑,并且因为我们正在黑客攻击它,所以文本会稍微移动一点(不确定为什么),但是如果添加以下行之后第hO0.onRelease(): dg.content_mc.header_mc.fHeaderCell0._y = dg.content_mc.header_mc.fHeaderCell1._y; – 2009-12-01 14:19:58

+0

谢谢乔治。我发现这个作品也是如此 dg.content_mc.header_mc.hO0.onPress(); dg.content_mc.header_mc.hO0.onRelease();它似乎做了完整的新闻和发布,并修复了它。太好了!再次感谢 – Dave 2009-12-01 16:01:28