RecordGridのソート(昇順・降順)の判別

【ご質問】
一定の固定値に対して「昇順,降順」と切り替えた場合でも、固定値に関しては
常に同じ位置に表示したいと思っています。

RecordSortの「昇順、降順」の状態を判別するAPIは存在するのでしょうか。

【回答】
RecordSortの「昇順、降順」の状態を判別する標準APIは用意されておりません。
ただし、昇順、降順を判別するフラグを定義し、独自で実装することは可能だと思います。

詳細は以下のサンプルをご参照ください。

{curl 5.0,6.0,7.0,8.0 applet}
{curl-file-attributes character-encoding = “shift-jis”}

{let ascending?:bool = true}
{define-proc public {custom-sort rgc:RecordGridColumn}:RecordSort

    set rgc.grid.sort = {RecordSort
                                  {proc {r1:Record, r2:Record}:int
                                      let val:String = r1[“id”] asa String
                                      let val2:String = r2[“id”] asa String
                                      {if ascending? then
                                          {if (val == “”)  and (val2 == “”) then
                                              {return -1}
                                          else
                                              {return {r1.compare-field “id”, r2[“id”]}}
                                          }
                                          set ascending? = false
                                          {dump ascending?}
                                      else
                                          {if (val == “”)  or  (val2 == “”then
                                              {return 1}
                                          else
                                              {return {r1.compare-field “id”, r2[“id”]}}
                                          }
                                          set ascending? = true
                                          {dump ascending?}
                                      }
                                  }
                              }
    {if ascending? then
        set ascending? = false
        {dump ascending?}
     else
        set ascending? = true
        {dump ascending?}
    }
    {return
        rgc.grid.sort asa RecordSort
    }
}

{let rs:RecordSet = {RecordSet
                                {RecordFields
                                    {RecordField “id”, domain = String}
                                },
                                {RecordData id = “a”},
                                {RecordData id = “b”},
                                {RecordData id = “c”},
                                {RecordData id = “d”},
                                {RecordData id = “”},
                                {RecordData id = “”},
                                {RecordData id = “”},
                                {RecordData id = “e”},
                                {RecordData id = “f”},
                                {RecordData id = “g”},
                                {RecordData id = “h”},
                                {RecordData id = “i”},
                                {RecordData id = “3”},
                                {RecordData id = “2000”},
                                {RecordData id = “2000”},
                                {RecordData id = “j”}                       
                            }
}

{let rg:RecordGrid = {RecordGrid
                                 record-source = rs,
                                 automatic-columns? = false,
                                 {RecordGridColumn “id”, halign = “right”,
                                     sort-spec = custom-sort
                                 }
                             }
}

{let v:View = {View
                       width = 5in,
                       height = 5in,
                       rg
                   }
}
       
{v.show}