sortCompareFunction

 DataGridColumn有一个属性sortCompareFunction,是用来指定排序的比较函数的。函数原型:

       

        mySortCompareFunction(obj1:Object, obj2:Object):int

             obj1 — A data element to compare.

             obj2 — Another data element to compare with obj1.

The function should return a value based on the comparison of the objects:

        -1 if obj1 should appear before obj2 in ascending order.
        0 if obj1 = obj2.
        1 if obj1 should appear after obj2 in ascending order.
Note: The obj1 and obj2 parameters are entire data provider elements and not just the data for the item.
The default value is null.

实际使用的时候感觉并不是很人道,首先跟labelFunction不同,没有column:DataGridColumn参数,这样,如果有很多 column,那就不得不写同样数量的比较函数。另外,一般的排序,往往都是在比较实际显示出来的值,如果使用了LabelFunction,就很可能是 比较LabelFunction的返回值(也就是肉眼看到的显示在表格里的东东),这样也是有点繁琐,不过还是可以通过调用labelFunction再 计算一遍,比如:

        private function formTable_sortFunc_access(obj1:Object, obj2:Object):int {         

                return ObjectUtil.stringCompare(accessField.labelFunction(obj1, accessField),

                                                                  accessField.labelFunction(obj2, accessField));                        

        }

注:accessField是DataGridColumn的id,点击header的时候才会触发排序

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值