Curl Global Community
RecordGrid指定列のドラッグ不可 - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: RecordGrid指定列のドラッグ不可 (/showthread.php?tid=1090)



RecordGrid指定列のドラッグ不可 - rom - 06-02-2014

こんにちはー!

RecordGridの特定の列のみに対する制御の質問です。



ID列を左側から動かせないようにして
残りの列はドラッグして列を変更出来る様にすることが出来ません・・・

column-movable? だと列を全て動かせるか動かせないかの2択なので

指定列のみ・・・というような動作をさせたいです


且つ、ID列は固定列ということで幅の設定も出来ないようにしたいです。。。

ご教授お願いいたします。

Code:
{let rec_set:RecordSet=
    {RecordSet
        {RecordFields
             {RecordField "id"   ,domain = int,caption="ID"}
            ,{RecordField "name"   ,domain = String,caption="名前"}
            ,{RecordField "age"   ,domain = String,caption="年齢"}
            ,{RecordField "sex"   ,domain = String,caption="性別"}
        }
        ,{RecordData id=1,name="一郎",age="20才",sex="男"}
        ,{RecordData id=2,name="花子",age="18才",sex="女"}
        ,{RecordData id=3,name="次郎",age="16才",sex="男"}
        ,{RecordData id=4,name="良子",age="14才",sex="女"}
        ,{RecordData id=5,name="三郎",age="12才",sex="男"}
    }
}

{let RG:RecordGrid={RecordGrid record-source=rec_set}}
{RG.set-frozen-region 0,1}
{value RG}



RE: RecordGrid指定列のドラッグ不可 - dyoshida - 06-02-2014

Romさん こんにちは

列を固定するのにcolumn-movable?を使うというのはあってると思いますよ。
「指定列のみ」という設定を行う場合は、RecordGridColumnに対して設定することになるかと。

幅を固定する場合は、column-resizable?オプションがあります。

こんな感じで。
ただ、これではまだ他の列をドラッグしてID列の前にもってこれるのが難点ですね・・・
Code:
{let rec_set:RecordSet=
    {RecordSet
        {RecordFields
            {RecordField "id"   ,domain = int,caption="ID"}
            ,{RecordField "name"   ,domain = String,caption="名前"}
            ,{RecordField "age"   ,domain = String,caption="年齢"}
            ,{RecordField "sex"   ,domain = String,caption="性別"}
        }
        ,{RecordData id=1,name="一郎",age="20才",sex="男"}
        ,{RecordData id=2,name="花子",age="18才",sex="女"}
        ,{RecordData id=3,name="次郎",age="16才",sex="男"}
        ,{RecordData id=4,name="良子",age="14才",sex="女"}
        ,{RecordData id=5,name="三郎",age="12才",sex="男"}
    }
}

{let RG:RecordGrid={RecordGrid
                       record-source=rec_set,
                       {RecordGridColumn
                           "id",
                           column-movable? = false,
                           column-resizable?  = false
                       }
                   }
}
{RG.set-frozen-region 0,1}
{value RG}



RE: RecordGrid指定列のドラッグ不可 - rom - 06-03-2014

>dyoshidaさん

早めの回答有難うございます!

RecordGridColumnに対して設定すれば簡単にできるんですね!



しかしID列の前に持ってこれてしまうのが確かに難点ですね・・・



RE: RecordGrid指定列のドラッグ不可 - umemura - 06-04-2014

抜け道がありそうですが・・・。

Code:
||先頭でポジションを保持するカラム
{define-class public CustomRecordGridColumn {inherits RecordGridColumn}
  field public position-fix?:bool
  {constructor public {default
                          position-fix?:bool = false,
                          ...
                      }
    set self.position-fix? = position-fix?
    {construct-super {splice ...}}
  }
}

||CustomRecordGridColumn に位置を保持させるグリッド
{define-class public CustomRecordGrid {inherits RecordGrid}
  {constructor public {default
                          ...
                      }
    {construct-super {splice ...}}
  }

  {method public {move-column
                     source-index:int,
                     destination-index:int
                 }:void
    ||移動先のカラムが CustomRecordGridColumn.position-fix?=true なら
    ||カラムの移動自体をキャンセルする
    {if destination-index < self.columns.size - 1 then
        {type-switch self.columns[destination-index]
         case crgc:CustomRecordGridColumn do
            {if crgc.position-fix? then {return }}
        }
    }
    {super.move-column source-index, destination-index}
  }
}

{let rec_set:RecordSet=
    {RecordSet
        {RecordFields
            {RecordField "id"   ,domain = int,caption="ID"}
            ,{RecordField "name"   ,domain = String,caption="名前"}
            ,{RecordField "age"   ,domain = String,caption="年齢"}
            ,{RecordField "sex"   ,domain = String,caption="性別"}
        }
        ,{RecordData id=1,name="一郎",age="20才",sex="男"}
        ,{RecordData id=2,name="花子",age="18才",sex="女"}
        ,{RecordData id=3,name="次郎",age="16才",sex="男"}
        ,{RecordData id=4,name="良子",age="14才",sex="女"}
        ,{RecordData id=5,name="三郎",age="12才",sex="男"}
    }
}

{let RG:CustomRecordGrid=
    {CustomRecordGrid
        record-source=rec_set,
        {CustomRecordGridColumn
            "id",
            column-movable? = false,
            column-resizable?  = false
            ,position-fix? = true
        }
    }
}
{RG.set-frozen-region 0,1}
{value RG}



RE: RecordGrid指定列のドラッグ不可 - rom - 06-05-2014

> umemuraさん

ありがとうございます!
思い通りの操作に出来てとてもうれしいです!

今後ともご指導宜しくお願いします!



抜け道というのが気になります。。。!