Thread Rating:
  • 343 Vote(s) - 2.85 Average
  • 1
  • 2
  • 3
  • 4
  • 5
編集不可のグリッドにデータを貼り付けたい
09-10-2013, 12:48 PM,
#2
RE: 編集不可のグリッドにデータを貼り付けたい
貼り付けコマンド「RecordGridPaste」をカスタマイズして対応するのがよいかもしれないですね。
with マクロを使って、貼り付け処理のときだけ編集可能にしています。

エクセルと振舞いを合わせるために、貼り付け時に、選択範囲を変更することも
このクラスをカスタマイズすればできそうですね。

Code:
{define-class public open CustomPaste {inherits RecordGridPaste}
  {constructor public {default context:RecordGrid}
    {construct-super context}
  }
  {method public {do-command allow-prompt?:bool = true}:void
    {if not self.context.editable? then
        def ret-val  = {popup-question "対象のグリッドは編集不可ですが、強制的に貼り付けますか?"}
        {if ret-val == Dialog.yes then

            {with self.context.editable? = true do
                {super.do-command allow-prompt? = allow-prompt?}
            }
        }
    else
        {super.do-command allow-prompt? = allow-prompt?}
    }
  }
}

{define-class public CustomPasteControlRecordGrid {inherits RecordGrid}
  {constructor public {default ...}
    {construct-super {splice ...}}
  }
  {method public {create-command name:String}:#Command
    {switch name
    case "paste" do
        def  paste-command = {CustomPaste self}
        {return paste-command}
    else
        {return {super.create-command name}}
    }
  }
}

{let rs:RecordSet =
    {RecordSet
        {RecordFields
            {RecordField "First", domain = String},
            {RecordField "Last", domain = String},
            {RecordField "Age", domain = int}
        }
        ,
        {RecordData First = "John", Last = "Smith", Age = 25},
        {RecordData First = "Jane", Last = "Smith", Age = 29},
        {RecordData First = "Jane", Last = "Jones", Age = 28}
    }
}

{def paste-grid =
    {CustomPasteControlRecordGrid
        record-source = rs,
        editable? = false
    }
}

{value paste-grid}


{CommandButton
    label = "貼り付け",
    {on Action do
        {if paste-grid.records.size == 0 then
            {if-non-null rs-tmp = paste-grid.record-source then
                {rs-tmp.append {rs-tmp.new-record}}
            }
        }
        {paste-grid.select-all}
        {paste-grid.do-command "paste"}
        {paste-grid.select-nothing}
    }
}

{CommandButton
    label = "全削除",
    {on Action do
        {rs.delete-all}
    }
}

{CommandButton
    label = "追加",
    {on Action do
        {rs.append {RecordData First = "John", Last = "Smith", Age = 25}}
    }
}



Messages In This Thread
RE: 編集不可のグリッドにデータを貼り付けたい - by umemura - 09-10-2013, 12:48 PM
Forum Jump:


Users browsing this thread:
3 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('965')