DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Deploying a Scala Play Application to Heroku: A Step-by-Step Guide
  • Spring Boot GoT: Game of Trace!
  • Using a Body With an HTTP Get Method Is Still a Bad Idea
  • Best Mobile App Development Frameworks and Trends in 2024

Trending

  • It’s Not About Control — It’s About Collaboration Between Architecture and Security
  • SQL Server Index Optimization Strategies: Best Practices with Ola Hallengren’s Scripts
  • 5 Best Node.js Practices to Develop Scalable and Robust Applications
  • A Modern Stack for Building Scalable Systems
  1. DZone
  2. Coding
  3. Frameworks
  4. ExtJS 4: How to Add Tooltip to Grid Header

ExtJS 4: How to Add Tooltip to Grid Header

This tutorial will walk through out how to add a tooltip to a Grid Header.

By 
Loiane Groner user avatar
Loiane Groner
·
Oct. 07, 11 · Tutorial
Likes (0)
Comment
Save
Tweet
Share
21.8K Views

Join the DZone community and get the full member experience.

Join For Free

this tutorial will walk through out how to add a tooltip to a grid header. this feature is not natively supported by ext js 4 api. fortunately,  there is a third-party plugin we can use to do it.

to get started, i created a javascript project on eclipse ide and it looks like this:

plugin code

the first thing we have to add (after ext js 4 sdk) is the plugin. to do so, i created a folder ux (for plugins) and a folder called grid (inside ux) because it is a plugin for ext 4 grid. then i created a file name headertooltip.js with the following content:

/**
 * @class ext.ux.grid.headertooltip
 * @namespace ux.grid
 *
 *  text tooltips should be stored in the grid column definition
 *
 *  sencha forum url:
 *  http://www.sencha.com/forum/showthread.php?132637-ext.ux.grid.headertooltip
 */
ext.define('ext.ux.grid.headertooltip', {
    alias: 'plugin.headertooltip',
    init : function(grid) {
        var headerct = grid.headerct;
        grid.headerct.on("afterrender", function(g) {
            grid.tip = ext.create('ext.tip.tooltip', {
                target: headerct.el,
                delegate: ".x-column-header",
                trackmouse: true,
                renderto: ext.getbody(),
                listeners: {
                    beforeshow: function(tip) {
                        var c = headerct.down('gridcolumn[id=' + tip.triggerelement.id  +']');
                        if (c  && c.tooltip)
                            tip.update(c.tooltip);
                        else
                            return false;
                    }
                }
            });
        });
    }
});

grid with header tooltip

now we need to build the application code. to test, simply create a data grid:

ext.loader.setconfig({enabled: true});

ext.require([
    'ext.grid.*',
    'ext.data.*',
    'ext.ux.grid.headertooltip'
]);

ext.onready(function() {

    var mydata = [
        ['3m co'],
        ['alcoa inc'],
        ['altria group inc'],
        ['american express company'],
        ['american international group, inc.'],
        ['at&t inc.'],
        ['boeing co.'],
        ['caterpillar inc.'],
        ['citigroup, inc.'],
        ['e.i. du pont de nemours and company'],
        ['exxon mobil corp'],
        ['general electric company']
    ];

    var store = ext.create('ext.data.arraystore', {
        fields: [
           {name: 'company'}
        ],
        data: mydata
    });

    ext.create('ext.grid.panel', {
        store: store,
        plugins: ['headertooltip'],
        columns: [
            {
                text     : 'company',
                flex     : 1,
                sortable : false,
                dataindex: 'company',
                tooltip: 'some tooltip'
            }
        ],
        height: 200,
        width: 200,
        title: 'grid with header tooltip',
        renderto: 'grid-example',
        viewconfig: {
            striperows: true
        }
    });
});

on line 1, we have to enable the ext.loader so ext can dynamic loading the files we need.

on lines 3-7 we declared the components we need to have loaded before loading our application. note the ext.ux.grid.headertooltip.js is included as well. this way, ext js knows it has to look for a file called headertooltip.js inside the folder ux/grid.

then on line 35 we have to include the headertooltip plugin as a plugin of the grid we want to display a header tooltip.

and finally, on line 42 we need to declared a column config called tooltip with the header tooltip we want to display.

html page

then we can create an html file we can run on a browser:

<html>
<head>
    <title>grid with header tooltip</title>

    <link rel="stylesheet" type="text/css" href="ext4/resources/css/ext-all.css" />
    <script type="text/javascript" src="ext4/ext-all.js"></script>

    <script type="text/javascript" src="app.js"></script>
</head>
<body>
    <div id="grid-example" style="padding:20px;"></div>
</body>
</html>

and when we execute the application, we will get the following:

and it is done!

disclaimer : i am not the author of this headertooltip plugin. so if you get any errors, please contact the author of the plugin on sencha forum: http://www.sencha.com/forum/showthread.php?132637-ext.ux.grid.headertooltip . i simply demonstrated how to use the plugin on this tutorial.

i’m using ext js 4.0.2a (open source version) on this project.

download the source code:

you can download the source code from:

my github: https://github.com/loiane/extjs4-grid-header-tooltip

happy coding! :)

  • subscribe to the comments for this post?
  • post to delicious
  • post to digg
  • post to twitter
    2
    2
    2
    2
    2
    2
    2
    2
    2
  • add to dzone
  • post to facebook
    1
    1
    1
    1
    1
    1
    1
    1
    1
  • add to linkedin
  • send via gmail
  • add to reddit
  • post to stumbleupon
  • add to technorati favorites
  • post on google buzz
  • share on google reader
  • add to google bookmarks
  • send via yahoo mail
  • add to friendfeed
  • post to blogmarks
  • post to yc hacker news
get shareaholic for firefox

from http://loianegroner.com/2011/10/extjs-4-how-to-add-tooltip-to-grid-header

Ext JS POST (HTTP)

Opinions expressed by DZone contributors are their own.

Related

  • Deploying a Scala Play Application to Heroku: A Step-by-Step Guide
  • Spring Boot GoT: Game of Trace!
  • Using a Body With an HTTP Get Method Is Still a Bad Idea
  • Best Mobile App Development Frameworks and Trends in 2024

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!