ExtJs – Hide Show Header Panel by Mouse Over

Kali ini saya akan berbagi cara memberikan bagaimana untuk memunculkan header panel ketika mouse over
dan menyembunyikan header panel ketika mouse leave.

Kurang lebih seperti berikut :

	Ext.create('Ext.panel.Panel', {
		title: '<font style="font-size: 9pt; color:white;">title of panel</font>',
			renderTo: target,
			width: 300,
			height: 300,
			header : {
				height : 35 / 768 * screen.height,
				style :"cursor: pointer; background: #000000; box-shadow: #000000 0 0 0 0 inset; border-width: 0px;"
			},
			listeners : {	
				render: function(thisPanel){
					thisPanel.getEl().on('mouseover', function() {
						thisPanel.getHeader().show();
					}, thisPanel);
					thisPanel.getEl().on('mouseleave', function() {
						thisPanel.getHeader().hide();
					}, thisPanel);
				}
			}
	});

Kalau kamu butuh menambahkan event ketika show dan hide header panel tersebut, maka header dari panel sudah meng-akomodir hal tersebut.
Kamu cukup menggunakan listeners show dan hide di header panel tersebut, seperti berikut :

	Ext.create('Ext.panel.Panel', {
		title: '<font style="font-size: 9pt; color:white;">title of panel</font>',
			renderTo: target,
			width: 300,
			height: 300,
			header : {
				height : 35 / 768 * screen.height,
				style :"cursor: pointer; background: #000000; box-shadow: #000000 0 0 0 0 inset; border-width: 0px;",
				listeners:{
					show: function(thisHeader){		
						alert("header is showing");
					},
					hide: function(thisHeader){
						alert("header is hide");
					}
				}
			},
			listeners : {	
				render: function(thisPanel){
					thisPanel.getEl().on('mouseover', function() {
						thisPanel.getHeader().show();
					}, thisPanel);
					thisPanel.getEl().on('mouseleave', function() {
						thisPanel.getHeader().hide();
					}, thisPanel);
				}
			}
	});

Terima kasih dan semoga bermanfaat.

mazipan-signature

Be a good reader, leave your comment please.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s