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_Related Related Topics sp_TopicIcon
How to set custom tooltip content?
07/09/2011
16:38
Avatar
PawelRoman
Member
Members
Forum Posts: 3
Member Since:
07/09/2011
sp_UserOfflineSmall Offline

Hi, this is a very simple question: how do I set a custom tooltip that would appear when hovering over a grid cell? I'm talking about HTML title attribute in grid's <td> element.

It seems that there is title flag in options but it allows only for switching on/off the title. How can I actually set this title to my own custom value for given cell?

07/09/2011
16:54
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

You can use cellattr attribute in the colModel for a column to set custom tooltip. For example

cellattr: function () { return ' title="my custom fixed tooltip for the column"'; }

define the attribute as a fixed text. I use such form for grid having many checkboxs. In the case I set just the column title as the tooltip.

Another more full form can be

cellattr: function (rowId, val, rawObject) {
    return rawObject[4] === "1" ? ' title="verified"' : ' title="not verified"';
}

In the case one can use val (the cell value) and the rawObject - the raw representation of the row of data. It has the same format as in JSON/XML data which you use to fill the data. So instead of rawObject[4] you could have to use rawObject.myColName.

Best regards
Oleg 

07/09/2011
17:17
Avatar
PawelRoman
Member
Members
Forum Posts: 3
Member Since:
07/09/2011
sp_UserOfflineSmall Offline

Thanks for quick answer. What if my title is not a static text but is a custom value depending on a cell value (but it is not a cell value itself)? How do I pass such value?

07/09/2011
18:06
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

I wrote you in the previous answer that cellattr attribute can be a function which has up to three parameters. The second parameter is the cell value (val).

cellattr: function (rowId, val) {
    return val === "foo" ? ' title="bar"' : ' title="You should do ' + val + '!!!"';
}

You can even test for the values from other columns of the same row and generate a title based on the values from many

columns.cellattr: function (rowId, val, rawObject) {
    return ' title="' + rawObject.firstName + ' ' + rawObject.lastName '"';
}

Best regards
Oleg

08/09/2011
10:17
Avatar
PawelRoman
Member
Members
Forum Posts: 3
Member Since:
07/09/2011
sp_UserOfflineSmall Offline

I was unclear, sorry. Imagine I have a table with 3 columns, In the first row, cell values are "A", "B", "C", I pass these values in XML they are redered OK. Now, i want to have a tooltip when hovering over a cell "A", and the tooltip content must be "D" (which as you see has nothing to do with ANY cell data). How do I send this "D" value to the grid? Of course it is a dynamic value thet I prepare on a server side, not a static 'd' letter. Do I have to have an extra hidden column for it or something like this?

08/09/2011
18:31
Avatar
J
Jupiter, Florida
Member
Members
Forum Posts: 6
Member Since:
21/09/2010
sp_UserOfflineSmall Offline

PawelRoman said:I was unclear, sorry. Imagine I have a table with 3 columns, In the first row, cell values are "A", "B", "C", I pass these values in XML they are redered OK. Now, i want to have a tooltip when hovering over a cell "A", and the tooltip content must be "D" (which as you see has nothing to do with ANY cell data). How do I send this "D" value to the grid? Of course it is a dynamic value thet I prepare on a server side, not a static 'd' letter. Do I have to have an extra hidden column for it or something like this?


Do something like this:

loadComplete: function (data){
                        var arr =jQuery("#grid").jqGrid('getDataIDs');
                        for(var i = 0; i <  arr.length; i++ ){
                                var d = jQuery("#grid").getRowData(arr[i]);

    jQuery("#grid").jqGrid('setCell', arr[i],<cellName of A>, <value of item to go into cell> ,"", {title: d.D});

}

look at my code here :http://www.trirand.com/blog/?page_id=393/help/how-to-stop-nselectrow-from-being-called-in-both-the-grid-and-subgrid/

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
30 Guest(s)

Currently Browsing this Page:
1 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