Tootltip for cells based in database field

QuestionsTootltip for cells based in database field
Alejandro asked 5 years ago

Hi Team and Friends!

Could you be so kind to assist me in how can I set the ToolTip feature for individual cells based in other field of my database

for example, I have to fields for a product.

Stocks and Sales

I want to show Stocks in a cell and the Sales in a tooltip for this product (in this cell showing stock)

Thanks you in advance.

3 Answers
Abu Ghufran answered 5 years ago

I'll update you after preparing a demo.

Abu Ghufran answered 5 years ago

You can set custom formatter to set custom tooltip (title attr).

For e.g. if you want to have cell with tooltip of column 'company', then formatter would be:

$col["formatter"] = "function(cellvalue, options, rowObject){ return '<div title="'+rowObject.company+'">'+cellvalue+'</div>'; }";

Unformat function will also be required for editing raw text:

$col["unformat"] = "function(cellvalue, options, rowObject){ return jQuery.jgrid.stripHtml(cellvalue); }";

Column settings:

$col = array();
$col["title"] = "Company";
$col["name"] = "company";
$col["editable"] = true;
$col["edittype"] = "textarea";
$col["editoptions"] = array("rows"=>2, "cols"=>20);
$cols[] = $col;

$col = array();
$col["title"] = "Client Name";
$col["name"] = "name";
$col["formatter"] = "function(cellvalue, options, rowObject){ return '<DIV title="'+rowObject.company+'">'+cellvalue+'</DIV>'; }";
$col["unformat"] = "function(cellvalue, options, rowObject){ return $.jgrid.stripHtml(cellvalue); }";
$col["editable"] = true;
$col["width"] = "80";
$cols[] = $col;

Full code: http://pastebin.com/ENKjryJ1

Alejandro answered 5 years ago

THANKS YOU!… It's works perfect!

Your Answer

11 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?