PDA

View Full Version : Hyperlink to displayfield



Pravin.Pawar
25 Jan 2013, 6:03 AM
Hi,

I have used displayfield in ExtJS to show read only values and wanted to provide hyper link so that user can navigate to other page.

Please let me know how to enable hyperlink and attach url link.

Thanks, Pravin

kvdk8_7
25 Jan 2013, 6:12 AM
use render listener to call a method and from the method return link as below:

function getLinkRenderer(value, obj, record) {
return '<a href ="javascript: jascriptMethod()">' + value + '</a>';
}

existdissolve
25 Jan 2013, 6:12 AM
Try using autoEl:



{
xtype: 'displayfield',
value: 'Google',
autoEl: {
tag: 'a',
href: 'http://google.com',
target:'_blank'
}
}

Pravin.Pawar
29 Jan 2013, 6:34 AM
This is NOT working over ExtJS form... can i use any other way?

existdissolve
29 Jan 2013, 6:48 AM
Which is not working? Can you post your code?

sword-it
29 Jan 2013, 7:01 AM
Hi,

Try the following code-




{
xtype: 'displayfield',
value: '<a href ="www.google.com">Google</a>'
}

Pravin.Pawar
29 Jan 2013, 7:11 AM
your code works somehow NOT sure how to open URL in new window. I coded like -

{
xtype: 'box',
autoEl: {
tag: 'a',
href: 'http://www.google.com/',
cn: 'Google'
},
listeners: {
render: function (c) {
c.on('click', function (e) {
alert('You clicked me!');
}, c, { stopEvent: true });
}
}
}

Above code also open URL in the same window. Please let me know how can I open URL in new window.

sword-it
30 Jan 2013, 3:15 AM
Try the below code-




{
xtype: 'box',
autoEl: {
tag: 'a',
href: 'http://www.google.com/',
target: '_blank' // for open in new window
cn: 'Google'
},

Pravin.Pawar
30 Jan 2013, 5:09 AM
Thanks... target='_blank' was missed out in my code and it works fine now.

I have dashboard where the list is displayed and on row click I'm opening form dialog window where I need to set display values with hyperlink which will navigate to respective record from other app.

Now the issues is when I'm opening dialog window first time; my code owrks fine... somehow next time hyperlinks displays old values... i mean the values of first time window load.

Please let me know how should I clear old values from the hyperlink and repalce with new values.. Im using following code which works fine for first time window load-

var lastIncidentNo = Ext.getCmp('lastincidentnoid');
lastIncidentNo.autoEl.cn = results.IncidentNo;
lastIncidentNo.autoEl.href = 'http://Google.com/' + results.IncidentNo;