JSGrid and Hyperlinks

Now, I might be wrong in this but there is a rather significant flaw in JSGrid.  This is the inbuilt Javascript based Grid for SharePoint 2010.  It is actually very handy to use, if not particularly SharePoint-y.  (For example, when connecting to a SharePoint list, you have to copy the data of out a SPListItemCollection into a DataTable, which doesn’t seem great to me.)

Anyway, if you use a Hyperlink in the JSGrid, it will always open in a new page.  This is massively annoying, not to mention counter-intuitive.  So what is the solution?

There isn’t one.

Basically, the Hyperlink class has two properties, Display and Address.  I’ve dug into the workings of JSGrid and there is a JSGrid.js file in <%14HIVE%>/TEMPLATE/LAYOUTS.  Having had a poke around, I found what I think is the problem.

if(d.bHyperlink)return function(){ULSEWi:;window.open(d.GetAddress(a))}

This looks like – and I stress I may be completely wrong – the bit of code that fires the link, and it is hard-coded to window.open which will always open that new window.

I’ve played around with jQuery and not managed to actually stop the event from firing properly on a regular basis.  I’ve tried stuff like event.preventDefault(), .unbind() and so on.  The closest I’ve got is to .unbind() on the first click of a hyperlink, but it insists on working second time around, so I think there is a refresh going on somewhere.

I’ll leave this one for now to more capable jQuery people, but if you are investigating this further, remember that the HyperLink class sticks the target URL in the click event, not the href of the <a> tag, so simply removing the click event won’t work.

A colleague has suggested a new class inheriting from Hyperlink, which I’ll have a look at.

Seems a lot of work for a simple thing, but that is SharePoint for you.


Posted on October 16, 2012, in SharePoint and tagged , , . Bookmark the permalink. 2 Comments.

  1. have you found any solution for this?

Leave a Reply

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: