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
Add image in tooltip
16/09/2010
02:18
Avatar
betty
Member
Members
Forum Posts: 22
Member Since:
24/06/2009
sp_UserOfflineSmall Offline

Using the custom formatter, I can add images to jqgrid cells. But the images are in their small version, and I would like to add a tooltip for the images. Basically, users can view the big version of image when they mouseover the small image.

I played with the setCell function and assigned image src directory to 'title'. The tooltip displayed, but just the string of image src.

My question is how to add the actual image in the tooltip?

setCell(rowid, 'colName', '','',{'title':"<img sr='/images/picture_big.jpg'>"})

Thanks very much.

16/09/2010
03:08
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

setCell can be used set only title attribute on the corresponding <td> html element like <td title="My ToolTip">. So setting of html code on the place of html attributes will not work.

To implement the behavior which you need you have to bind all <td> elements (grid cells) with mouseover and mouseout functions which will be display the custom tooltips with images. You can do such binding inside of loadComplete event handle.

To make your implementation easy you can try to use some existing ToolTip plugin like http://bassistance.de/jquery-p.....n-tooltip/, http://plugins.learningjquery......l and so on.

Best regards
Oleg 

25/11/2010
03:27
Avatar
Candrairawan78
Indonesia
Member
Members
Forum Posts: 39
Member Since:
30/01/2010
sp_UserOfflineSmall Offline

Dear all,

I have tried to use tooltip above and did not success, does anybody can guide me with a working sample tumbnail image hover pease?I have a project with a lot of goods and i need tumbnail images to make it easy.

Best regards,

Candra

30/11/2010
01:24
Avatar
ppr
France
Member
Members
Forum Posts: 13
Member Since:
17/02/2009
sp_UserOfflineSmall Offline

Hi all,

I used an extension called jquery.qtip plugin to do this in my application.
And it works well with Firefox and IE.
To see the plugin for dynamically loaded thumbnail tooltip, see this example here:

http://craigsworks.com/project...../thumbnail

You can apply the same way in Jqgrid.
To see an example, take the "JSON Data" sample in "Loading data section" section of jqgrid demo.
You want to show a thumbnail tooltip when the cursor is on "Inv No" column.
You define that "inv no" column content is the basename of an image called "<content>.jpg" file.
So, the content "1″ will show in a tooltip the "1.jpg image", "2″ shows in a tooltip the "2.jpg" image and so on…
To do this, on the server side, make a folder "images" containing all the image files 1.jpg to 13.jpg.

In jqgrid, to link  the column "Inv No" content with a thumbnail tooltip, insert the code (in jsonex.js) after ColModel, line 14 with the
"loadComplete" event handle like this:

        loadComplete : function() {
            $("#list2 tr").each(function(){
                    var col1= $(this).find("td:eq(0)"); // First column Inv No
                    var thumbnail_url="images/"+$(col1).html()+".jpg"; // Build image link
                    $(col1).removeAttr("title"); // Remove old title
                    var image='<img src="'+thumbnail_url+'" alt="Chargement imagette…" width=100 height=100 />';
                    $(col1).qtip({
                                 content: image,
                                 position: {
                                    corner: {
                                       tooltip: 'bottomMiddle',
                                       target: 'topMiddle'
                                    }
                                 },
                                 style: {
                                    tip: true, // Give it a speech bubble tip with automatic corner detection
                                    name: 'blue'
                                 }
                    });
                });

               }, // loadComplete

You have to download the jquery.qtip extension at:
http://bazaar.launchpad.net/~c...../1.0/files
Note: you need this special version because it fixes a bug in the ajax content download
(For more explanation: http://craigsworks.com/project.....ax-and-net )
Put the downloaded version in a folder js/jquery.qtip
                              
And declare the jquery.qtip extension in the head of (jqgrid.html) in the javascript section like this:
  <script src="js/jquery.qtip/jquery.qtip-1.0.min.js" type="text/javascript"></script>

To summerize, if your Jqgrid_demoXX is installed on your hard disk on <your path>, the new folders were here:

<your path>Jqgrid_demo36/images

<your path>Jqgrid_demo36/js/jquery.tip

Two files to change: <your path>Jqgrid_demo36/jqgrid.html

                                <your path>Jqgrid_demo36/jsonex.js

Hope this will help.

01/12/2010
14:19
Avatar
Candrairawan78
Indonesia
Member
Members
Forum Posts: 39
Member Since:
30/01/2010
sp_UserOfflineSmall Offline

Dear ppr,

Thank you for your guide to jquery qtip. I was success to follow your step but I got problem when I want to change thumbnail tooltip when the cursor is on "Tax" column (fifth column).

I have changed the code to:

var col1= $(this).find("td:eq(4)"); // Fifth column Tax

and the image did not show.

Could you help me solve this problem, please? Thank you

Best Regards,

Candra

01/12/2010
15:08
Avatar
Candrairawan78
Indonesia
Member
Members
Forum Posts: 39
Member Since:
30/01/2010
sp_UserOfflineSmall Offline

Dear all,

You gave an example that "inv no" column content is the basename of an image called "<content>.jpg" file.
So, the content "1″ will show in a tooltip the "1.jpg image", "2″ shows in a tooltip the "2.jpg" image and so on…

How if I want to have a thumbnail based on primary ID of a row?

for example a row with primary ID = xxx will show in a tooltip the "xxx.jpg image" and so on...

Best Regards,

Candra

02/12/2010
10:15
Avatar
ppr
France
Member
Members
Forum Posts: 13
Member Since:
17/02/2009
sp_UserOfflineSmall Offline

Hi Candra,

I try answering to your 2 questions:

1/ How to show the tooltip image on "Tax" column (and take the content from "Inv No" Column) ?

In your example, You can do that:
 - After the line

var col1=...

 you add this line:
  

 var col4= $(this).find("td:eq(4)");

 - and you replace the line
    

$(col1).qtip({

by this one:
    

$(col4).qtip({

Now the tooltip image will show on "Tax" column and the image tooltip is build from "Inv No" column.
    
 
2/ How to show the tooltip image where the basename of image file is based on content from "ID of row" ?


In this Jqgrid example, the "id" of row is localized in the html code "<tr id="<content ID row>" ... >".
So you need to get the content of the attribute of "id" from "<tr...>".
To do this:

- after the line in your example

var col1=...

you add this line:
 

var idrow = $(this).attr("id");

- and you replace this line:
       

var thumbnail_url="images/"+$(col1).html()+".jpg";

by this one:
        

var thumbnail_url="images/"+idrow+".jpg";

 Hope this will help.

 
 Best regards
 Phil

02/12/2010
17:37
Avatar
Candrairawan78
Indonesia
Member
Members
Forum Posts: 39
Member Since:
30/01/2010
sp_UserOfflineSmall Offline

Dear Phil,

Yoou are awesome. It works. It helped me so much.

Thank you very much.

Best Regards,

Candra

11/01/2012
23:15
Avatar
vivek.patel
Los Angeles,CA
Member
Members
Forum Posts: 3
Member Since:
10/01/2012
sp_UserOfflineSmall Offline

Hi,

I want to have a toop tip on my JQuery Grid and i tried the method you have described but it does not work for me.

I want to add a toop tip which contrains both some text and image or screen shot. Please help me.

Thanks,

Vivek

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
89 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