Thread Rating:
  • 472 Vote(s) - 2.79 Average
  • 1
  • 2
  • 3
  • 4
  • 5
入力チェックについての質問です
04-06-2014, 09:24 PM,
#4
RE: 入力チェックについての質問です
自分もRecordGridのバリデーションチェックはどのようにするのがよいのか悩んでいるのですが・・・

FocusOutしたときにnote-grid-focus-outが呼ばれない件は、フォーカスとグリッドフォーカスは
まったく同じものではなくて、フォーカスがRecordGridとは別のコントロールに移動しても、
破線で囲われたセルにグリッドフォーカスがあるのでは?

FocusOutはon-focus-outメソッドをオーバーライドすれば取れるのではと思うのですが、
ダイアログを表示した際などにもフォーカス移動が発生するので制御が面倒そうです。

ただ、本来やりたかったことを考えると値を入力した際のチェックなので、Record更新時の
update-dataを使うというのはどうでしょうか?

他に考慮しなければならないことがありそうですが、とりあえずupdate-dataを使うように
コードを変更してみました。
Code:
{import * from CURL.LANGUAGE.REGEXP}

{define-class public Check-name {inherits StandardStringCell}
  {constructor public {default}
    {construct-super}
  }
  ||置換前
  field before_text:String=""
  
  ||置換後(数字)
  field after_text_suuji:String = ""
  
  ||チェックする値(数字)
  field chk_suuji:String = "[0-9]"
  
||--  {method public {note-grid-focus-out}:void
||--    {super.note-grid-focus-out}
  {method public {update-data val:any}:#DataException
    def de = {super.update-data val}
    {if-non-null de then
        return de
    }
    
    ||フォーカスを受けていたセルの値を保存する(置換前)
    set self.before_text = {String {super.get-data}}
    
    ||置換する(数字)
    set self.after_text_suuji =
        {regexp-subst
            self.chk_suuji
            ,self.before_text
            ,""
            ,replace-all?=true
        }
    
    ||
    {if {self.before_text.equal? self.after_text_suuji}
     then
||++    {set self.background = "white"}
        {unset self.background}
     else
        {popup-message "・数字が入力されています"}
        {after 0s do {self.become-active}}
        {set self.background = "red"}
    }
    
    {return null}
  }
}

{let people:RecordSet=
    {RecordSet
        {RecordFields
            {RecordField "名前"}
            ,{RecordField "年齢"}
        }
        ,{RecordData 名前 = "テスト君" , 年齢 = "25"}
        ,{RecordData 名前 = "テストさん", 年齢 = "37"}
    }
}

{let test:RecordGrid=
    {RecordGrid
        record-source = people
        ,{RecordGridColumn "名前" ,width=50,cell-spec = Check-name}
        ,{RecordGridColumn "年齢" ,width=50}
    }
}

{let hozon:CommandButton=
    {CommandButton
        label="保存"
        ,{on Action do
             {people.commit}
         }
    }
}

{value
    {VBox
        test
        ,hozon
    }
}


Messages In This Thread
RE: 入力チェックについての質問です - by dyoshida - 04-06-2014, 09:24 PM
Forum Jump:


Users browsing this thread:
1 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('1063')