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.
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.