Hi,
I am using webgrid 7.1 on .NET 1.1
I have a webgrid with a column that is of type "HyperLink".
In that column i set the TargetURL to a javascript function using "java_script:OpenAudit(x)", this happens from code behind. Now the user click on a column to sort it. Sorting is done on clientside. After the sort, the TargetURL of each row is reset, and the hyperlink does not work anymore.
function AuditGrid_AfterXmlHttpResponseProcessed(gridName)
{
var grid = igtbl_getGridById(gridName);
var row = grid.Rows.getRow(rowcounter);
var id
var idcell = row.getCellFromKey("Id");
var id = idcell.getValue();
var actioncodecell = row.getCellFromKey("ActionCode");
var url = "java_script:OpenAudit('"+ id + "')";
actioncodecell.setTargetURL(url);
}
Remark:To test remove the _ from java_script!!!
Sorry for the bad formatting, both apparently the editor does a crappy job of copy-paste from visual studio 2003
Thanks for sharing the solution in forums - much appreciated. I will double check what can be done to have this addressed internally without breaking backwards compatibility.
For whomever is interested, the CSOM method setTargetURL is i.m.o incorrect. Below i have submitted the solution. i have implemented the function myself (as i do not want to change CSOM, otherwise upgrades would make the problem come back). I have included the part of the code that needs to be changed to make this work. I do not know this would work with "ordinary links" but for "script links" this works pretty good.
var el = actioncodecell.Element.firstChild;
//following was hard to figure out!!!
el = el.firstChild;
//set href
el.href="java_script:OpenAudit('"+ id + "')";
//set target
el.target = "_self";