I did have to make some changes to the code I orginally posted to make it work properly in IE. IE kept wanting to bring up the href link as well as the js link.
It also makes the new window or window link you clicked on come into focus.
The fixed code is:
“/* for use with jslink */
function
openChildWindow(cUrl, cName, cFeatures) {
var cName = window.open(cUrl, cName, cFeatures);
if (window.focus)
cName.focus();
return false;
}”
“$.fn.fmatter.jslink = function(cellval, opts) {
var op = {baseLinkUrl: opts.baseLinkUrl, addParam: opts.addParam || “”, target: opts.target, idName: opts.idName },
target =
“”, idUrl;
if(!isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
switch(op.target)
{
case 'unique_by_row':
target = op.idName+opts.rowId+cellval;
// so every different link will open in it's own window
break;
case 'unique':
target = op.idName+cellval;
// if we have a colums where some cell values in the same column that can be exactly the same, such as vendor, publisher, brand, etc.
break;
default:
target = op.target;
}
idUrl =
'onclick=”openChildWindow('' + op.baseLinkUrl + '?' + op.idName + '=' + cellval + '','' + target +'',''+ op.addParam + ''); return false;”';
if(isString(cellval) || isNumber(cellval)) { //add this one even if its blank string
return '<a ' + idUrl + '>' + cellval + '';
}
else {
return $.fn.fmatter.defaultFormat(cellval,opts);
}
};”
After doing extensive searching, I was able to find a post that said how to do this.
Open up the ui.jqgrid.css file and change the 3rd line in the /* body */ section to this:
.ui-jqgrid tr.jqgrow td {font-weight: normal; overflow: hidden; white-space: normal !important; height:22px; padding: 0 2px 0 2px;border-bottom-width: 1px; border-bottom-color: inherit; border-bottom-style: solid;}
The only difference is that “white-space:” is changed from “pre” to “normal !important”.
O.k., thanks for the help.
Here is the resulting code in case you are interested. And it should be XHTML 1.1 strict compliant.
“function openChildWindow(cUrl, cName, cFeatures) {
var cName = window.open(cUrl, cName, cFeatures);
return false;
}”
“$.fn.fmatter.jslink = function(cellval, opts) {
var op = {baseLinkUrl: opts.baseLinkUrl, addParam: opts.addParam || “”, target: opts.target, idName: opts.idName },
target =
“”, idUrl;
if(!isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if(op.target)
{
if(op.target == 'unique')
{target = op.idName+opts.rowId+cellval;}
// so every different link will open in it's own window
else
{target = op.target;}
}
idUrl =
'onclick=”return openChildWindow(' + 'this.href,'' + target +'',''+ op.addParam + ''); return false;”';
if(isString(cellval) || isNumber(cellval)) { //add this one even if its blank string
return '<a href="' + op.baseLinkUrl + '?' + op.idName + '=' + cellval + '”' + idUrl + '>' + cellval + '';
}
else {
return $.fn.fmatter.defaultFormat(cellval,opts);
}
};
“
Sample colmodel:
{ name: 'itemNum', index: 'itemNum', formatter:'jslink', formatoptions:{baseLinkUrl:'whatever.HTML', idName:'itemNum', target:'unique', addParam:'height=200,width=400'}, width: 80, sorttype: “int” },
Other then changing that how are you supposed to get the cell data to be sent in the URL with the current code?
Seems kind of non-functional if you need to send the cell data through the URL.
In what instance is somebody going to need to send the row Id unless you have another script to grab the cell data from the column and row?
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top