Forum
16:38
07/09/2011
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?
16:54
10/08/2009
You can use cellattr attribute in the colModel for a column to set custom tooltip. For example
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
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
18:06
10/08/2009
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).
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
return ' title="' + rawObject.firstName + ' ' + rawObject.lastName '"';
}
Best regards
Oleg
10:17
07/09/2011
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?
18:31
21/09/2010
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/
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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66