Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

[Feature Request] Cell tooltip support #492

Closed
sejoker opened this issue Apr 22, 2014 · 4 comments
Closed

[Feature Request] Cell tooltip support #492

sejoker opened this issue Apr 22, 2014 · 4 comments

Comments

@sejoker
Copy link

sejoker commented Apr 22, 2014

First of all, thank you for the great OSS project.

I have a requirement to support tooltip for grid's cells. I didn't find any similar feature requests so I would like to discuss here how we could support this in Backgrid. In my opinion this thing is totally optional and should be implemented as Backgrid extension. As a draft implementation I propose something as simple as possible:

(function(Backgrid){
    'use strict';

    var cellRender = Backgrid.Cell.prototype.render; 
    Backgrid.Cell.prototype.render = function () {
        var that = cellRender.call(this),
            value = that.$el.text();

        // apply tooltip after cell value evaluation
        if (value){
            that.$el.attr('title', value);
        }

        return that;
    }
}(Backgrid))

Please share your opinion about the provided solution.

@bruno-c
Copy link
Collaborator

bruno-c commented Apr 26, 2014

I'm not sure I understand, you are showing the text inside the cell as a tooltip? You are seeing the text by looking at the cell, why would you want to show it again in the tooltip?

I can see how maybe additional information could be shown using the title attribute, but if it's going to show what's in the cell anyways...

@wyuenho
Copy link
Contributor

wyuenho commented Apr 27, 2014

What @bruno-c says.

@sejoker
Copy link
Author

sejoker commented Apr 28, 2014

The reason is the following:
I know that column resizing feature isn't supported out of box, but according to the suggestions from #6 it's easy to plug in. Сolumn resizing can lead to text being cut so cell's tooltip becomes valuable:

backgrid

@wyuenho wyuenho removed the wontfix label Apr 28, 2014
@wyuenho
Copy link
Contributor

wyuenho commented Apr 28, 2014

Not every built-in cell type needs a title. UriCell and EmailCell for example have the title attributes set in the anchor, and you really don't want to show the tooltip of the cell content for the textcell extension. But I understand having to adjust the CSS is a half solution.

While this feature should be optional, the default settings need to be reasonable as well, i.e. cells without anchors should come with a title on the cell by default if and only if when truncated. The best course seems to have to involve an event handler to detect column size changes when #6 comes along.

PR welcome.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants