flex_DataGridColumn中文按照首字母拼音排序

阅读更多
整个页面全粘出来了!
费时费力啊,整了好长时间,不知道还有没有别的好的方法。。。


        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

   
                import mx.collections.Sort;
            import mx.utils.ObjectUtil;
            import mx.utils.StringUtil;
   public  function isIn(min:int,max:int,n:int):Boolean{
      return min<=n && max>=n;
    }
   public  function convertChar(chineseChar:String):String
    {
   if(chineseChar!=null){
    var bytes:ByteArray = new ByteArray
     var str:String;
     for(var i:int=0;i    bytes.writeMultiByte(chineseChar.charAt(i), "cn-gb");
    var n:int = bytes[i] << 8;
    n += bytes[i+1];
  
    if (isIn(0xB0A1, 0xB0C4, n))
     str=str+"a";
    if (isIn(0XB0C5, 0XB2C0, n))
     str=str+"b";
    if (isIn(0xB2C1, 0xB4ED, n))
     str=str+"c";
    if (isIn(0xB4EE, 0xB6E9, n))
    str=str+"d";
    if (isIn(0xB6EA, 0xB7A1, n))
     str=str+"e";
    if (isIn(0xB7A2, 0xB8c0, n))
    str=str+"f";
    if (isIn(0xB8C1, 0xB9FD, n))
     str=str+"g";
    if (isIn(0xB9FE, 0xBBF6, n))
     str=str+"h";
    if (isIn(0xBBF7, 0xBFA5, n))
     return "j";
    if (isIn(0xBFA6, 0xC0AB, n))
     str=str+"k";
    if (isIn(0xC0AC, 0xC2E7, n))
     str=str+"l";
    if (isIn(0xC2E8, 0xC4C2, n))
     str=str+"m";
    if (isIn(0xC4C3, 0xC5B5, n))
     str=str+"n";
    if (isIn(0xC5B6, 0xC5BD, n))
     str=str+"o";
    if (isIn(0xC5BE, 0xC6D9, n))
     str=str+"p";
    if (isIn(0xC6DA, 0xC8BA, n))
     str=str+"q";
    if (isIn(0xC8BB, 0xC8F5, n))
     str=str+"r";
    if (isIn(0xC8F6, 0xCBF0, n))
    str=str+"s";
    if (isIn(0xCBFA, 0xCDD9, n))
     str=str+"t";
    if (isIn(0xCDDA, 0xCEF3, n))
    str=str+"w";
    if (isIn(0xCEF4, 0xD188, n))
    str=str+"x";
    if (isIn(0xD1B9, 0xD4D0, n))
     str=str+"y";
    if (isIn(0xD4D1, 0xD7F9, n))
     str=str+"z";
   
     }
     return str;
    }
    return null;
    }
  
    private function value_sortCompareFunc(itemA:Object, itemB:Object):int {
      if (!itemA.hasOwnProperty("value")) {
                    itemA.value = null;
          }
               // Make sure itemB has a "value" property.
               if (!itemB.hasOwnProperty("value")) {
                   itemB.value = null;
              }
             
         var str1:String= convertChar(itemA.value);
           var str2:String=convertChar(itemB.value);
      return ObjectUtil.stringCompare(str1, str2, checkBox.selected);
             
   }
        ]]>
   

   
       
           
               
                
                
               
               
              
           
               
           

       

   


   
                        label="case insensitive search:"
                labelPlacement="left"
                selected="true" />
   


   
       
           
           
       

   






你可能感兴趣的:(flex,xml,flexexamples)