Implementing informative tooltips in JSGrid header

After spending a considerable amount of time researching how to implement a suitable tooltip for JsGrid, I have come up with the following solution:

headerTemplate: function() { 
    return $("<div>").text(this.title)
         .append('<div class="tooltip"><img height="20" width="20" id="tooltip" src="https://cdn4.iconfinder.com/data/icons/ionicons/512/icon-ios7-help-outline-128.png" /><span class="tooltiptext">Tooltip text</span></div>');

However, the issue with this tooltip is that when it contains a long text, it gets cut off by the JsGrid Header due to its overflow-x: hidden and overflow-y: scroll properties.

To address this problem, I tried setting the position of the tooltip to position:absolute, but this caused misplacement when the grid did not fit entirely on the screen.

I discovered that surrounding the element with overflow set in CSS with a <div> having position: relative, allows me to use a nested position: absolute div to override it. However, since the grid is dynamically generated through Javascript, I am contemplating if there is an alternative approach or if I need to modify the JsGrid generation process.

You can view the complete example at: https://jsfiddle.net/SlowFing/1hx84hv7/

Answer №1

I've found a solution that works for me:

headerTemplate: function () {
    var tableHeader = $('<th class="text-center"></th>');
    return tableHeader.prop("title","boo" ).text("column title");
}

Answer №2

To implement the tooltip feature, you must set the header cell to have a position:relative property and then absolutely position the tooltip. Make sure to follow these modifications suggested below..https://jsfiddle.net/5pbv2crq/9/

Cascading Style Sheets (CSS)

.table-header-cell {
    position:relative;
}

.tooltip {
   position: absolute;
   display: inline-block;
   border-bottom: 1px dotted black;
}

.tooltip .tooltip-info::after {
   content: "";
   position: absolute;
   top: 10%;
   right: 100%;
   margin-top: -5px;
   border-width: 5px;
   border-style: solid;
   border-color: transparent black transparent transparent;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

unable to insert logo into HTML

I am customizing an HTML template, but the dimensions of the logo in the template are smaller than my logo. Despite adding my logo to the template, it is not showing up. @media (max-width: 673px) { #logo { margin-left: 20px; } } #header #logo ...

Ways to display information using a show/close button in React

I am currently immersed in the learning process of React. My goal is to display information about different countries using a toggleable button. However, I have encountered some obstacles along the way. There's an input field that triggers upon enteri ...

Issue with transition delays on specific elements within a containing element

I'm currently developing an intro animation for a website, where the children are supposed to slide up from the bottom (margin-top: 80px). The container is set with a fixed height and overflow:hidden to create a smooth appearance. Each child has a tr ...

Retrieve the object filtered by a specific group from an array of data

I have a data object that contains various groups and rules within each group item. My task is to filter the rules based on a search query, while also displaying the group name associated with the filtered rule. { "id": "rulesCompany", "group": [ ...

Positioning an element within a div with a fixed width and height in a somewhat precise manner

Here is my current HTML markup: <div id="content"> <img src="some_content.jpg"> <form action="..."> <input type="text" ... > <input type="submit" ...> </form> <div id="forgotyourpassword"> ...

Vue alert: Issue encountered in watcher 'childItems' callback - 'TypeError: Unable to access property 'tag' as it is undefined'

I am currently in the process of developing the Store page for a web application. I am utilizing Axios to retrieve product data and display it in a Vue template. While the backend functionality is working correctly and the frontend is rendering successfull ...

Avoiding using the symbols < and > in JavaScript code before assigning it to InnerHtml

I am dynamically adding JavaScript code to a script tag by setting the InnerHtml property of the HtmlNode. scriptNode.InnerHtml = new_script; The issue arises when my JavaScript code contains less than < and/or greater than > characters, which dist ...

Tips for showing icon-based message boxes in ASP.NET using C#

Is there a way to show a message box with different icons (like Warnings/errors/Information) in ASP.NET3.5 using C#? I tried the following code, but it didn't work as expected. ClientScript.RegisterStartupScript(this.GetType(), "Message", "alert(&ap ...

Javascript and JSON: Making Updates to Files

Working on a program, I am faced with an issue while sending a literal variable to local storage using JSON.stringify. My goal is to continuously update the local storage and append to the existing data stored. The problem arises during the parsing of the ...

Article Topic: Alerting Users of Unnecessary CSS File Load in Next.js App

I'm encountering an error with this Next.js code: The code utilizes Shadcn for the UI and Convex as a backend. Here is my folder structure: https://i.sstatic.net/zOvubRg5.png Below is my main layout file: import type { Metadata } from "next&q ...

display a div based on the user's choice

I am working with the following http://jsbin.com/useqa4/10 My query revolves around hovering over li elements in the submenu using the code snippet below: $(".submenuList li").hover(function () { $(".submenuCurrent").removeClass("submenuCurrent"); $( ...

Can multiple meshes share the same geometry while having different shaderMaterials applied to each?

After creating a single PlaneGeometry instance, I proceeded to create 200 meshes that share this geometry and each have their own unique shaderMaterial instance. Below is a simplified version of the code snippet: ... var geom = new THREE.PlaneGeometry(10 ...

Is there a way to create a Bootstrap table that is responsive and includes a

I have a bootstrap table and I am trying to display the contents of a database in its tbody. However, I am facing an issue with achieving a responsive vertical scroll only within the tbody while keeping the header fixed. I have experimented with CSS by set ...

I am looking to create a PHP script that restricts access to individuals under the age of 18 based on the current

I'm looking for a way to use Php, javascript, or ajax to restrict access for individuals under 18 years old based on the current date. Any suggestions on how I can achieve this? Could someone please review my code for calculating age onblur or onSubm ...

What are the best scenarios for employing Server Side Includes?

The documentation for Apache regarding SSI mentions that it is a convenient method to incorporate small snippets of information, like the current time. However, if most of your webpage content is being dynamically generated when served, then it suggests ...

The span is unresponsive

When focusing on an input or checking its validity, the span should move up but it's not responding to any styles. <div class="login"> <span class="logtxt">Username or email</span> <input type=& ...

What could be the reason for the 'if' statement not being assessed in the 'then' promise of the ajax request?

I'm facing an issue with an ajax call in my code. I have a 'then' promise set up to handle errors, where the console log returns false correctly when there is an error. However, for some reason, the if condition in the next line is not being ...

Warning: Typescript is unable to locate the specified module, which may result

When it comes to importing an Icon, the following code is what I am currently using: import Icon from "!svg-react-loader?name=Icon!../images/svg/item-thumbnail.svg" When working in Visual Studio Code 1.25.1, a warning from tslint appears: [ts] Cannot ...

Background image not showing on div element

As someone who is new to coding, I could really use some assistance with a problem I've encountered. Specifically, I'm attempting to reference an image within a div element, but unfortunately it's not displaying when I check through my brows ...

Changing the color of a selected list element using an Angular directive

I'm currently facing an issue with my directive that is supposed to turn a list element red when clicked. It works fine, but I also want it to revert back to black when another list item is selected, so only one item stays in red color. Here is how I ...