Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
custom formatter issue
21/10/2011
16:28
Avatar
milad
Member
Members
Forum Posts: 33
Member Since:
03/10/2011
sp_UserOfflineSmall Offline

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.

24/10/2011
23:22
Avatar
boson
Member
Members
Forum Posts: 5
Member Since:
06/10/2011
sp_UserOfflineSmall Offline

Hi,

As a general tip, I would like to suggest that you look at the data in options and rowObject. The easiest way is to just do console.log(options) with FireBug.

Boson

Forum Timezone: Europe/Sofia

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

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information