Can any one please help to make my label as hyperlink in Sencha EXT JS.
Asked
Active
Viewed 9,296 times
4 Answers
1
Here is a solution of your problem: [hyperlink in Sencha EXT JS]: how to create hyper link in extjs4?
or you can add new event for your label:
Ext.onReady(function() {
var yourLabel = new Ext.form.Label({
id:'yourLabel',
text: 'http://your-link-here.com',
renderTo : document.body
});
Ext.getCmp('yourLabel').getEl().on('click',function(){
window.open("http://your-link-here.com");
});
});

Community
- 1
- 1

Nail Shakirov
- 654
- 1
- 8
- 17
-
That doesn't make it a hyperlink – Ruan Mendes Aug 27 '13 at 06:35
-
1It should work, I update my answer, first you make your link clickable and after just add realization into your function like in my code. With css you can make your label underlined and change text color. – Nail Shakirov Aug 27 '13 at 07:03
-
1But it still won't let me right click and open in a new tab, or let me just drag it to another window. My point is that it's not a hyperlink, it's a workaround. See my answer – Ruan Mendes Aug 27 '13 at 18:29
1
You can just tell the fieldLabel to be a link http://jsfiddle.net/EsppR/1/
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
renderTo: Ext.getBody(),
items: {
xtype: 'textfield',
name: 'name',
fieldLabel: '<a href="http://www.google.com">Name</a>',
allowBlank: false // requires a non-empty value
}
});

Ruan Mendes
- 90,375
- 31
- 153
- 217
1
Two ways:
//1st - set html for label
{
xtype: "label",
html: "bla bla?! <a href='http:/\tiny.cc/snir' target='_blank'>Press This Link!!!</a><br>"
},
//2nd - create a new component
{
xtype: 'component',
autoEl: {
tag: 'a',
href: 'http:\/tiny.cc/snir/',
target: '_blank',
html: 'tiny.cc/snir'
}
}
You can see my example here https://fiddle.sencha.com/#view/editor&fiddle/1kqh and inspect the differents.

snir
- 2,961
- 1
- 17
- 10
0
As a plugin:
Ext.define('YourCompany.plugins.LinkedLabel', {
extend: 'Ext.AbstractPlugin',
url: undefined,
init: function (cmp) {
this.setCmp(cmp);
cmp.beforeLabelTextTpl = '<a href="' + url + '">';
cmp.afterLabelTextTpl = '</a>';
});
});
Use:
{
xtype: 'textfield',
fieldLabel: 'Linked label',
plugins: Ext.create('YourCompany.plugins.LinkedLabel', { url: '/yourUrl' })
}

Evgeni Nabokov
- 2,421
- 2
- 32
- 36