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 tooltip/title in row?
26/01/2010
23:41
Avatar
glittle
Member
Members
Forum Posts: 31
Member Since:
23/01/2010
sp_UserOfflineSmall Offline

Question 1:

Assume I have 3 columns of data:  A, B, C

What I want to to hide columns B and C, but use their data in a tool tip on column A.

Can this be done using a custom formatter?

How would I access the other columns, and how do I set the tool tip?

Question 2:

For column D, the text may be too long to show in a column. I want to only show, say, 50 characters in the cell. The full text would be shown in the tooltip.

Can this be done using a custom formatter?

Thanks,

Glen

28/01/2010
17:45
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

In the current implementation (case 1) it is not possible to use formatter for this purpose, beqouse of the rendering engine, which call first the formatter and then we construct the tooltip.

One possible solution is to use grid complete event and then you can loop througth the rows  (you should get the ids) and set the title attribute of the coulmn.

For case 2 I think that this is the default behaviour of the grid or I'm missiing something

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

28/01/2010
18:45
Avatar
glittle
Member
Members
Forum Posts: 31
Member Since:
23/01/2010
sp_UserOfflineSmall Offline

Thanks for the reply.

For case 2, you are right…

In a related question, I'm finding that the headings for each column do not cut off. So, if the column is too narrow, the text continues on and overwrites the header of the next column. Is there any way to fix this?

Glen

28/01/2010
19:08
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Not sure if I understand. The text in the heading column shod behave as the data. Also which version is used?

Could you please send a link to the problem or post a code?

Thanks

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

28/01/2010
19:35
Avatar
glittle
Member
Members
Forum Posts: 31
Member Since:
23/01/2010
sp_UserOfflineSmall Offline

Here is an example...

[Image Can Not Be Found]

As you can see, the headers don't get cut off.

Here are settings from my jqGrid() setup:

    height: 'auto',
    width: '1024px',
    cellEdit: true,
    autowidth: true,
    shrinkToFit: true,

and the column model:

{name:'P2010HrsAchieved',index:'P2010HrsAchieved',label:'2010 Billable Hrs YTD Achieved',width:150,search:false,resizable:false,editable:true},
{name:'P2010RevGoalCurrency',index:'P2010RevGoalCurrency',label:'2010 Revenue Goal Currency',width:150,search:false,resizable:false,editable:true},
{name:'P2010RevGoal',index:'P2010RevGoal',label:'2010 Revenue Goal',width:150,search:false,resizable:false,editable:true},

Is my only option to manually set the column size?

Thanks,

Glen

29/01/2010
00:42
Avatar
OlegK
Germany
Member
Members
Forum Posts: 1255
Member Since:
10/08/2009
sp_UserOfflineSmall Offline

Hi Glen,

such strange look has long headers in old version of IE (in IE 6). How to fix the problem in IE6 I don’t now currently. Probably Tony could help you. In more modern versions of IE, the text in column headers will be cut off like you want. To add tooltips to headers I use code like

    // add tooltip on the column headers

    var grid = jQuery('#list').jqGrid({...});

    var thd = $("thead:first", grid.hDiv).get(0);

    for (var i = 0; i < cn.length; i++) {

        var tmp = "tr th:eq(" + (i + 1) + ")";

        $("tr th:eq(" + (i + 1) + ")", thd).attr("title", cn[i]);

    }

    $("tr th:eq(8)", thd).attr("title", "Ist Standardtest?");

where cn is colNames array (array with column headers). If you use empty colNames array and the give the same information in lable of colModel, you should change the code a little.

In my opinion tooltips on column headers could be implemented in jqGrid per default (what think Tony about that). But if you want to change tooltip for a some column to another text as the column name, you can use code like following

$("tr th:eq(8)", thd).attr("title", "Bla bla");

How to change default text of tooltip Tony wrote you before. Here is an code example:

jQuery('#list').jqGrid({

        loadComplete: function() {

            var ids = grid.getDataIDs();

            for (var i = 0; i < ids.length; i++) {

                var id = ids[i];

                var UserName = grid.getCell(id, 'UserName');

                var Telefon = grid.getCell(id, 'Telefon');

                var Mobile = grid.getCell(id, 'Mobile');

                var Email = grid.getCell(id, 'Email');

                var Location = grid.getCell(id, 'Location');

                var toolTip = UserName;

                if (Location !== '') toolTip += '\nLocation: ' + Location;

                if (Telefon !== '') toolTip += '\nTel: ' + Telefon;

                if (Mobile !== '') toolTip += '\nMobile: ' + Mobile;

                if (Email !== '') toolTip += '\nE-Mail: ' + Email;

                grid.setCell(id, 'UserName', '', '', { title: toolTip });

                // one can use grid.getRowData(id)

                // instead of grid.getCell

            }

        },

In the code fragment column UserName is visible and columns Telefon,Mobile,Email, Location - hidden. Information from the hidden columns used to set tooltip on the visible cells.

Best regards

Oleg

29/01/2010
02:55
Avatar
glittle
Member
Members
Forum Posts: 31
Member Since:
23/01/2010
sp_UserOfflineSmall Offline

Thanks Oleg!

I'll try what you suggested.

Glen

29/01/2010
02:56
Avatar
glittle
Member
Members
Forum Posts: 31
Member Since:
23/01/2010
sp_UserOfflineSmall Offline

For the column headings, I've manually adjusted the header text, and set the column width of each column to match...

02/02/2010
16:19
Avatar
forzafortuna
New Member
Members
Forum Posts: 1
Member Since:
02/02/2010
sp_UserOfflineSmall Offline

    // add tooltip on the column headers

    var grid = jQuery('#list').jqGrid({…});

    var thd = $("thead:first", grid.hDiv).get(0);

    for (var i = 0; i < cn.length; i++) {

        $("tr th:eq(" + (i + 1) + ")", thd).attr("title", cn[i]);

    }


Hi,

I used the above code to create header tooltips but failed to get it working in Firefox 3.5. This is my slightly adjusted code that works fine in IE8, Safari and Chrome:

gridComplete: function() {
    var thd = $("thead:first", grid.hDiv).get(0);
    for (var i = 0; i < myColums.length; i++) {
        $("tr th:eq(" + i + ")", thd).attr("title", myColums[i]);
    }
}

No errors in Firefox and no tooltip either. Does anyone has a fix for this issue?

05/02/2010
11:35
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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