Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

ydn-javascript · Yahoo! User Interface Library Group

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 12955
  • Category: JavaScript
  • Founded: Dec 15, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
Links in a DataTable   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages Sort by Date  
#17572 From: "ter31024" <ter@...>
Date: Sat Sep 1, 2007 7:34 pm
Subject: Links in a DataTable
ter31024
Send Email Send Email
 
Hello,

I'm still fairly new at YUI and am having trouble getting links
configured in a DataTable. I have added the
'YAHOO.widget.DataTable.formatLink' method as a parameter to my column
definitions and that succeeds in making the cell data equal to the
HREF. However, what I would like to do is append an 'html' extension
to this. I.e. the cell data would say "servers" but it would link to
"servers.html"

It seems the only way to do this is to override the formatLink method
and I'm not having much luck with that. Is there an easier way to do
this?

Any guidance in the right direction would be appreciated.
Tom




#17573 From: "Satyam" <satyam@...>
Date: Sat Sep 1, 2007 8:26 pm
Subject: Re: Links in a DataTable
satyamutsa
Send Email Send Email
 
In the DataSource, you could do:

responseSchema.fields = [ ... , {key:'myLink',parser:function(link) {return
link + '.html'}}, ... ]

or otherwise you could either redefined the formatLink method or define your
own separate function based on formatLink and assign it to formatter.

Satyam

----- Original Message -----
From: "ter31024" <ter@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Saturday, September 01, 2007 9:34 PM
Subject: [ydn-javascript] Links in a DataTable


> Hello,
>
> I'm still fairly new at YUI and am having trouble getting links
> configured in a DataTable. I have added the
> 'YAHOO.widget.DataTable.formatLink' method as a parameter to my column
> definitions and that succeeds in making the cell data equal to the
> HREF. However, what I would like to do is append an 'html' extension
> to this. I.e. the cell data would say "servers" but it would link to
> "servers.html"
>
> It seems the only way to do this is to override the formatLink method
> and I'm not having much luck with that. Is there an easier way to do
> this?
>
> Any guidance in the right direction would be appreciated.
> Tom
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.484 / Virus Database: 269.13.1/982 - Release Date: 31/08/2007
> 17:21
>
>




#17651 From: "ter31024" <ter@...>
Date: Tue Sep 4, 2007 3:13 pm
Subject: Re: Links in a DataTable
ter31024
Send Email Send Email
 
Hello,

Thanks for the assistance. I've decided that it'd make the most sense
to simply override the formatLink formatter in this instance.
Unfortunately, I'm not having much luck doing that either. Here is
what I have...

==========================================

YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
el.InnerHTML = '<a href=" + oData + '.html">' + oData + '</a>';
}

var myColumnDefs = [{
key: 'A_HOST_HOSTNAME',
sortable: true,
formatter: YAHOO.widget.DataTable.formatLink
}];

==========================================

So, for example if the A_HOST_HOSTNAME key is "server1" a link will
automatically be generated as http://server/server1. What I'd like to
do is change that link to server1.html.

The above code doesn't do that though, it generates an error:

'missing ; before statement'
YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {\n

I just don't get it :-( ... If I remove the override, the error goes
away. There must be an easier way to simply generate a link in a
datatable. Any help at all would be greatly appreciated.

Thanks,
Tom




#17678 From: "sudermatt" <sudermatt@...>
Date: Wed Sep 5, 2007 4:52 am
Subject: Re: Links in a DataTable
sudermatt
Send Email Send Email
 
OK,  I have another question related to this....

If I have a column in the my data that contains an ID value, and
another column that contains a label.

UserID
UserName

How can I set up the formatter function so that the UserName column
displays the UserName as a link to a page sending the UserID

viewUser.asp?UserID=xxxxx






#17656 From: "Satyam" <satyam@...>
Date: Tue Sep 4, 2007 4:40 pm
Subject: Re: Re: Links in a DataTable
satyamutsa
Send Email Send Email
 
You override function has a quote missing right after href=".  That accounts
for the error, which is somewhat missleading because the compiler is quite
cunfused reading text for code and vice versa.

Those errors are easy to catch if you use some IDE or an editor with color
coding. I personally use Notepad++
(http://notepad-plus.sourceforge.net/uk/site.htm) and I've read good
comments in this list about Aptana as an IDE. Both are free.

Satyam

----- Original Message -----
From: "ter31024" <ter@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Tuesday, September 04, 2007 5:13 PM
Subject: [ydn-javascript] Re: Links in a DataTable


> Hello,
>
> Thanks for the assistance. I've decided that it'd make the most sense
> to simply override the formatLink formatter in this instance.
> Unfortunately, I'm not having much luck doing that either. Here is
> what I have...
>
> ==========================================
>
> YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
> el.InnerHTML = '<a href=" + oData + '.html">' + oData + '</a>';
> }
>
> var myColumnDefs = [{
> key: 'A_HOST_HOSTNAME',
> sortable: true,
> formatter: YAHOO.widget.DataTable.formatLink
> }];
>
> ==========================================
>
> So, for example if the A_HOST_HOSTNAME key is "server1" a link will
> automatically be generated as http://server/server1. What I'd like to
> do is change that link to server1.html.
>
> The above code doesn't do that though, it generates an error:
>
> 'missing ; before statement'
> YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {\n
>
> I just don't get it :-( ... If I remove the override, the error goes
> away. There must be an easier way to simply generate a link in a
> datatable. Any help at all would be greatly appreciated.
>
> Thanks,
> Tom
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
> 9:31
>
>




#17657 From: "ter31024" <ter@...>
Date: Tue Sep 4, 2007 5:25 pm
Subject: Re: Links in a DataTable
ter31024
Send Email Send Email
 
Thanks for the help Satyam, it is really appreciated.

I've corrected the missing quote, also corrected 'el.InnerHTML' to
'el.innerHTML' and am still getting the same error. The odd thing is,
if I do something like this:

YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
el.innerHTML = "Hello World";
}

The error still shows. Above this override is just the usual
'YAHOO.util.Event.addListener(window, "load", function() {' line...
and if I comment out the overload entirely, the error goes away.

I'm wondering if I am doing something wrong with trying to overload
this function. I am trying to pass 'el' based on what I read in the
Yahoo API under formatLink's arguments. Checking the example of an
overload,
http://developer.yahoo.com/yui/examples/datatable/dt_formatting.html,
the overloaded formatter is formatMail and that accepts an 'elCell' as
the first argument. In addition, it uses
YAHOO.widget.Column.formatEmail which I think is just a shortcut. I'm
lost. :-(





#17659 From: "Satyam" <satyam@...>
Date: Tue Sep 4, 2007 6:03 pm
Subject: Re: Re: Links in a DataTable
satyamutsa
Send Email Send Email
 
Sorry, not paying enough attention, the 'function' is missing

YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn, oData) {
el.innerHTML = "Hello World";
};


----- Original Message -----
From: "ter31024" <ter@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Tuesday, September 04, 2007 7:25 PM
Subject: [ydn-javascript] Re: Links in a DataTable


> Thanks for the help Satyam, it is really appreciated.
>
> I've corrected the missing quote, also corrected 'el.InnerHTML' to
> 'el.innerHTML' and am still getting the same error. The odd thing is,
> if I do something like this:
>
> YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
> el.innerHTML = "Hello World";
> }
>
> The error still shows. Above this override is just the usual
> 'YAHOO.util.Event.addListener(window, "load", function() {' line...
> and if I comment out the overload entirely, the error goes away.
>
> I'm wondering if I am doing something wrong with trying to overload
> this function. I am trying to pass 'el' based on what I read in the
> Yahoo API under formatLink's arguments. Checking the example of an
> overload,
> http://developer.yahoo.com/yui/examples/datatable/dt_formatting.html,
> the overloaded formatter is formatMail and that accepts an 'elCell' as
> the first argument. In addition, it uses
> YAHOO.widget.Column.formatEmail which I think is just a shortcut. I'm
> lost. :-(
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
> 9:31
>
>




#17662 From: "ter31024" <ter@...>
Date: Tue Sep 4, 2007 6:33 pm
Subject: Re: Links in a DataTable
ter31024
Send Email Send Email
 
Satyam, you rock!

Thanks so much. All is working great now.




#17663 From: "ter31024" <ter@...>
Date: Tue Sep 4, 2007 6:46 pm
Subject: Re: Links in a DataTable
ter31024
Send Email Send Email
 
Ooof, I celebrated too soon.  Now this is bizarre.  Everything is
working great in Firefox, however, if you load the page in IE7 the
links are completely gone and the cells are empty!

What I have is...

YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn,
oData) {
el.innerHTML = '<a href="/views/' + oData + '.html>' + oData + '</a>';
};

This overrides the default formatLink perfectly and gives me want I
want. Works like a charm in Firefox, however, now the links just show
up blank in IE6 and IE7. Not sure if it is a YUI bug or something I
need to add/am doing wrong.

Thanks,
Tom

--- In ydn-javascript@yahoogroups.com, "ter31024" <ter@...> wrote:
>
> Satyam, you rock!
>
> Thanks so much. All is working great now.
>





#17669 From: "Satyam" <satyam@...>
Date: Tue Sep 4, 2007 6:58 pm
Subject: Re: Re: Links in a DataTable
satyamutsa
Send Email Send Email
 
You are missing a double qute after '.html">


----- Original Message -----
From: "ter31024" <ter@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Tuesday, September 04, 2007 8:46 PM
Subject: [ydn-javascript] Re: Links in a DataTable


> Ooof, I celebrated too soon. Now this is bizarre. Everything is
> working great in Firefox, however, if you load the page in IE7 the
> links are completely gone and the cells are empty!
>
> What I have is...
>
> YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn,
> oData) {
> el.innerHTML = '<a href="/views/' + oData + '.html>' + oData + '</a>';
> };
>
> This overrides the default formatLink perfectly and gives me want I
> want. Works like a charm in Firefox, however, now the links just show
> up blank in IE6 and IE7. Not sure if it is a YUI bug or something I
> need to add/am doing wrong.
>
> Thanks,
> Tom
>
> --- In ydn-javascript@yahoogroups.com, "ter31024" <ter@...> wrote:
>>
>> Satyam, you rock!
>>
>> Thanks so much. All is working great now.
>>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
> 9:31
>
>




#17687 From: "Satyam" <satyam@...>
Date: Wed Sep 5, 2007 6:57 am
Subject: Re: Re: Links in a DataTable
satyamutsa
Send Email Send Email
 
var myFormatter = function(el, oRecord, oColumn, oData) {

el.innerHTML = '<a href="page.php?userID=' + oRecord.getData('UserID') +
'">' + oData + '</a>';

};

You assign it as a formatter for the UserName column so the UserName comes
in the oData argument. The UserID you pick from the record.

Satyam

----- Original Message -----
From: "sudermatt" <sudermatt@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Wednesday, September 05, 2007 6:52 AM
Subject: [ydn-javascript] Re: Links in a DataTable


> OK, I have another question related to this....
>
> If I have a column in the my data that contains an ID value, and
> another column that contains a label.
>
> UserID
> UserName
>
> How can I set up the formatter function so that the UserName column
> displays the UserName as a link to a page sending the UserID
>
> viewUser.asp?UserID=xxxxx
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
> 9:31
>
>




 
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help