RecordGridのソートについて

【ご質問】
RecordGridにて、「特定カラムの昇順・降順のソートを第1条件とし、
その他カラムの昇順を第2条件とする」にはどのようにしたらよいのでしょうか。

【回答】
第1条件対象の”特定カラム”のsort-specに昇順か降順かの設定を行い、
第2条件対象の”その他カラム”のsort-specにnullを設定することで実現可能です。

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

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

{let records:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField
                “id”, caption = “row no”, domain = int,
                index-type = RecordFieldIndexType.unique
            },
            {RecordField “level”, domain = String},
            {RecordField “Lv1”, domain = String},
            {RecordField “Lv2”, domain = String},
            {RecordField “Lv3”, domain = String},
            {RecordField “Lv4”, caption = “金額”, domain = int}
        },
        {RecordData id = 1,  level = “1”,     Lv1 = “Fred”,  Lv2 = “”,          Lv3 = “”,  Lv4 = 700},
        {RecordData id = 2,  level = “1-1”,   Lv1 = “Fred”,  Lv2 = “Cambridge”, Lv3 = “”,  Lv4 = 450},
        {RecordData id = 3,  level = “1-1-1”, Lv1 = “Fred”,  Lv2 = “Cambridge”, Lv3 = “E”, Lv4 = 150},
        {RecordData id = 4,  level = “1-1-2”, Lv1 = “Fred”,  Lv2 = “Cambridge”, Lv3 = “F”, Lv4 = 300},
        {RecordData id = 5,  level = “1-2”,   Lv1 = “Fred”,  Lv2 = “Boston”,    Lv3 = “”,  Lv4 = 100},
        {RecordData id = 6,  level = “1-2-1”, Lv1 = “Fred”,  Lv2 = “Boston”,    Lv3 = “Z”, Lv4 = 100},
        {RecordData id = 7,  level = “1-3”,   Lv1 = “Fred”,  Lv2 = “Hartford”,  Lv3 = “”,  Lv4 = 150},
        {RecordData id = 8,  level = “1-3-1”, Lv1 = “Fred”,  Lv2 = “Hartford”,  Lv3 = “A”, Lv4 = 150},
        {RecordData id = 9,  level = “2”,     Lv1 = “Pat”,   Lv2 = “”,          Lv3 = “”,  Lv4 = 950},
        {RecordData id = 10, level = “2-1”,   Lv1 = “Pat”,   Lv2 = “Keene”,     Lv3 = “”,  Lv4 = 700},
        {RecordData id = 11, level = “2-2”,   Lv1 = “Pat”,   Lv2 = “New Haven”, Lv3 = “”,  Lv4 = 100},
        {RecordData id = 12, level = “2-3”,   Lv1 = “Pat”,   Lv2 = “Concord”,   Lv3 = “”,  Lv4 = 150},
        {RecordData id = 13, level = “2-3-1”, Lv1 = “Pat”,   Lv2 = “Concord”,   Lv3 = “E”, Lv4 = 150},
        {RecordData id = 14, level = “3”,     Lv1 = “Glenn”, Lv2 = “”,          Lv3 = “”,  Lv4 = 611},
        {RecordData id = 15, level = “3-1”,   Lv1 = “Glenn”, Lv2 = “Storrs”,    Lv3 = “”,  Lv4 = 306},
        {RecordData id = 16, level = “3-1-1”, Lv1 = “Glenn”, Lv2 = “Storrs”,    Lv3 = “O”, Lv4 = 103},
        {RecordData id = 17, level = “3-1-2”, Lv1 = “Glenn”, Lv2 = “Storrs”,    Lv3 = “Q”, Lv4 = 102},
        {RecordData id = 18, level = “3-1-3”, Lv1 = “Glenn”, Lv2 = “Storrs”,    Lv3 = “S”, Lv4 = 101},
        {RecordData id = 19, level = “3-2”,   Lv1 = “Glenn”, Lv2 = “Storrs2”,   Lv3 = “”,  Lv4 = 305},
        {RecordData id = 20, level = “3-2-1”, Lv1 = “Glenn”, Lv2 = “Storrs2”,   Lv3 = “I”, Lv4 = 155},
        {RecordData id = 21, level = “3-2-2”, Lv1 = “Glenn”, Lv2 = “Storrs2”,   Lv3 = “M”, Lv4 = 150}
    }
}

{let sort1:RecordSort = {RecordSort {proc {x:Record, y:Record}:int
                                        {let x-val:String = x[“level”] asa String}
                                        {let y-val:String = y[“level”] asa String}
                                        {set x-val = {x-val.substr 0, 1}}
                                        {set y-val = {y-val.substr 0, 1}}
                                        {if {x.compare-field “Lv1”, y[“Lv1”]} != 0 then
                                            {return {x.compare-field “Lv1”, y[“Lv1”]}}
                                         else
                                            {return {(x[“level”] asa String).compare (y[“level”] asa String)}}
                                        }
                                    }
                        }
}
{let sort2:RecordSort = {RecordSort.from-string “Lv2, level”}}

{let record-grid:RecordGrid =
    {RecordGrid
        record-source = records,
        height = 15cm,
        width = 20cm,
        {RecordGridColumn “id”, edit-on-focus? = false, sort-spec = null},
        {RecordGridColumn “level” ,sort-spec = null},
        {RecordGridColumn “Lv1”, sort-spec = {RecordSort.from-string “Lv1 ASC”}},
        {RecordGridColumn “Lv2” ,sort-spec = null},
        {RecordGridColumn “Lv3” ,sort-spec = null},
        {RecordGridColumn “Lv4” ,sort-spec = null}
    }
}

{View
    title = “Grid sample”,
    {Frame width = 21cm, height = 16cm,
        {VBox
            record-grid
        }
    },
    visibility = “normal”,
    {on WindowClose do
        {exit}
    }
}