:: Forum >> Version 1 >>

simple clickable hyperlink from an XML data source..


Hi,
Nice tool it is but and lot of the posts have been of great help to me but I am kind of stuck on a little thing I am trying to do..
Very simple in fact.
I am opening an xml and displaying certisn elements in a table fashion style.
Everything goes fine until I manage to set a row into an URL style.

when I do :
var link = new Active.Templates.Link;
link.setAttribute("target", "_new");
obj.setColumnTemplate(link, 2);

The column 10 is well changed into an hyperlink kind and I can click on the cells (btw there seem to be a little bug, when the cell is empty it is style in hyperlink fashion..) it links to "nothing", what is logical becaus eit didnt set any data in the link property...

So navigating the forum I have found this code :

obj.setProperty("data/link", function(i, j){
if(j==2) return myData[i][5];
});

to do a basic tests I switched it to
obj.setProperty("data/link", "www.activewidgets.com");

and BLAM! I get an error " object doesnt support this property or method , line 24 Char 7335 )

I do not understand why...is it becaus I am using an XML data source ?
Additionnally I couldnt use the myData[i][5] to return the correct cell content.what is the way ?

thank you in advance !





Dragonmood
Sunday, November 28, 2004

I've found in the forum something that is working with an hard-coded url :

obj.setAction("click", function(src){
document.location.href = "http://www.google.com";
});

But if I set the link to the 10th column I get "" as link and this whichever row I click (all rows have a column 10 with an url) :

obj.setAction("click", function(src){
var i = src.getProperty("item/index");
document.location.href = this.getDataText(i,10);
});

I believe it is something to do with the "this.getDataText(i,10)"
It means get the content from row i and column 10 right ?....
I use xml data source.

Please someone tell me what I am doing wrong , thanks !
Dragonmood
Monday, November 29, 2004

I finally made it to work using the document.location.href property

obj.setAction("click", function(src){
var 
src.getProperty("item/index");
var 
src.getColumnProperty("index");
if (
j==10) { document.location.href this.getDataProperty("text"i10)} ;
 });

 
But why does not this code work ? :(

var table = new Active.XML.Table;
 ( ..)

 var 
link = new Active.Templates.Link
 
link.setAttribute("target""table");    
 
obj.setColumnTemplate(link10); 
 
obj.setProperty("table/link", function(ij){
 if(
j==10) return this.getDataProperty("text"i10); 
 }); 

 
I am very close to make it work so if someone see the error in the this line :
if(j==10) return this.getDataProperty("text", i, 10);

please tell me
Monday, November 29, 2004
if(j==10) {return this.getDataProperty("text", i, 10);});
/\
Carlos
Monday, November 29, 2004
_________/\
Monday, November 29, 2004
Sorry the last ')' is not needed

obj.setProperty("table/link", function(i, j){
if(j==10) return this.getDataProperty("text", i, 10);
};
-/\
Monday, November 29, 2004
if(j==10) {return this.getDataProperty("text", i, 10);};
Monday, November 29, 2004

hi,
thanks for the reply :)
your code seems to generate a "missing (" error so I reforulate it on a single line, see result below :
But it still ( *sob* ) redirect to "" (nothing)...
I am pretty sure that it is linked to the "table/link" name becaus eof most example it is "data/link"..but "data/link" refuses to work for my code...
table name comes from a created activewidjet object (?)
var table = new Active.XML.Table;

If you have any idea...

var link = new Active.Templates.Link
link.setAttribute("target""table");    
obj.setColumnTemplate(link10); 
    
obj.setProperty ("table/link", function(ij){ if(j==10) {return this.getDataProperty("text"i10)}} );

 
Tuesday, November 30, 2004
Well since this is th eonly working way I've found to add link feature to the table can someone tell me if using the below method I can specidfy a target page (I use framset) ?
this command does not seem to do the job ...

document.setAttribute("target", "left");

obj.setAction("click", function(src){
var 
src.getProperty("item/index");
var 
src.getColumnProperty("index");
if (
j==10) { 
document.location.href this.getDataProperty("text"i10);
document.setAttribute("target""left"); 
} ;

  });

 
Tuesday, November 30, 2004
I've edited link.js to add:
obj.setAttribute("target", function(){return this.getItemProperty("target")});

and whenever I use the link template:
link.setAttribute("target", function() {
return "foo_windowname";
});
elsigh
Thursday, April 7, 2005
I found another way of making a simple clickable hyperlink from an XML data source. Suppose the xml value in column 6 is www.example.com:

var link = new Active.Templates.Link;
link.setAttribute("target", "_blank");
link.setAttribute("href", function() {
return "http://" + this.getItemProperty("value");
});
obj.setColumnTemplate(link, 5);

The result is a hyperlink in a new window. The same of course for emailaddresses: replace "http://" into "mailto:"

Still one problem with empty cells (clicking returns in "0"). Any ideas? And how to implement a javascript alert after clicking the hyperlink (e.g. 'you are leaving my website')?
Rhaja
Friday, June 10, 2005
Referring to my previous question about implementing a javascript alert after clicking the hyperlink: well, very easy (of course):

link.setEvent('onclick', function popupMsg()
{
alert('My message');
});
Saturday, June 11, 2005
I used:

obj.setAction("click", function(src){ 
    var 
src.getProperty("item/index"); 
    var 
src.getColumnProperty("index"); 
    if (
j==0) { 
    var 
link this.getDataProperty("text"i1);
    
window.open(link);
    } ; 
    
      }); 
 
Works great!
shortmatt
Wednesday, July 27, 2005



This topic is archived.

Back to support forum

Forum search