Forum


16:28

03/10/2011

Hello. I have written several custom formatters for columns and they are working. However, one custom formatter that is given me an issue. If I do the following, then there are no syntax errors on the page when it loads and the alert message is displayed when I hover over a column cell for this column:
function FormatMenu(cellValue, options, rowObject) {
var cellHTML;
var spanID = 'spanTicker' + options.rowId;
cellHTML = "<span id='" + spanID + "' onmouseover=ShowMenuNew('" + spanID + "'," + options.rowId + ") onmouseout=HideMenu('')>" + cellValue + " <img src='/applications/images/icons/action_arrow.gif' alt='' /></span>";
return cellHTML;
}
function ShowMenuNew(tickerSpan, row) {
alert('ticker');
}
However, if I change the formatter function to pass in the rowObject or a JSON stringified version of the rowObject, I get a syntax error when the page loads:
function FormatMenu(cellValue, options, rowObject) {
var cellHTML;
var spanID = 'spanTicker' + options.rowId;
cellHTML = "<span id='" + spanID + "' onmouseover=ShowMenuNew('" + spanID + "'," + rowObject + ") onmouseout=HideMenu('')>" + cellValue + " <img src='/applications/images/icons/action_arrow.gif' alt='' /></span>";
return cellHTML;
}
Or this:
function FormatMenu(cellValue, options, rowObject) {
var cellHTML;
var spanID = 'spanTicker' + options.rowId;
var rowString = JSON.stringify(rowObject);
cellHTML = "<span id='" + spanID + "' onmouseover=ShowMenuNew('" + spanID + "','" + rowString + "') onmouseout=HideMenu('')>" + cellValue + " <img src='/applications/images/icons/action_arrow.gif' alt='' /></span>";
return cellHTML;
}
Any particular reason for this? I have tried several JS escape character but have not been able to get this to work. Ideally, I would like to pass the rowObject or a JSON string of the rowObject from my formatter fucntion to the ShowMenuNew function. Any thoughts?
Thank.
Most Users Ever Online: 715
Currently Online:
62 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66