1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

itemIdを指定してコンポーネントを取得する

Posted at

itemIdを指定してコンポーネントを取得する場合は、2種類の方法がある。
Ext.Queryable.downと、Ext.Queryable.queryByIdの2つ。

queryByIdのソース見るとdownを呼んでいるだけなので、itemIdの先頭に#をつけるのが好きか嫌いかだけの問題ですかね。

    queryById: function(id){
        return this.down('#' + id);
    },
Ext.onReady ->
	# 表示するビューオブジェクト
	view = null
	# 画面の構築
	cfg = 
		layout:'border'
		items:[
			region:'center'
			layout:'fit'
			tbar:[
				text:'test1'
				handler: ->
					# 親→子方向に検索 itemIdには、先頭に#を付ける
					item = view.down("#txtArea")
					console.log item.getValue()
			,
				text:'test2'
				handler: ->
					# itemIdには、先頭に#を付けない
					item = view.queryById("txtArea")
					console.log item.getValue()
			]
			items:
				xtype:'codemirror'
				theme: 'blackboard'
				mode: "text/x-coffeescript"
				itemId:'txtArea'   # <- itemIdを指定
				showToolbar:false
	# 画面の表示
	view = Ext.create("Ext.Viewport",cfg)


1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?