Persistent column menu in ag-grid

Is there a way to include a menu for each row within a sticky column in Ag-grid? I couldn't find any information about this feature in the official documentation, so I'm unsure if it's even possible. I've attempted several methods, but the menu always remains confined inside the sticky column wrapper. The only approach that seemed to work partially was by applying the following CSS: .ag-body-container .ag-row { z-index: 0; } .ag-ltr .ag-hacked-scroll .ag-pinned-right-cols-viewport { overflow: visible !important; } However, this caused issues with vertical scrolling. Here is an example of the column definitions used: [sample code here] And here is an example of the CSS styling applied for the menu: [sample CSS code here]

Answer №1

I have decided to completely shift away from the original idea of placing the menu within the cell.

Here is what I propose instead:

  • Place the menu outside the grid, hidden,
  • Retain the link within the cell (this will activate the menu later),
  • Add a click event to this link,
  • Create a universal class for the menu (since there will only be one menu with changing context),
    • This class will toggle the visibility of the menu,
    • It will also store the contextual data (such as information from your grid)
  • The click event on the links in the grid will include code to display the menu.

Here's an outline of the process: Please note that error handling has been omitted for brevity.

var gridMenu = function(selector) {
    var instance = this;
    instance.element = document.querySelector(selector);
    instance.context = null; // This can hold any relevant data based on your project

    // 'sender' refers to the link in your cell
    // 'context' represents your data (as mentioned above)
    instance.open = function(sender, context) {
        instance.context = context;
        
        instance.element.style.display('block');
        // Alternatively, you could use instance.element.classList.add('some_class_to_make_menu_visible')
        // Consider adding positioning code here (valuable data may come from 'sender')
    }

    instance.close = function () {
        instance.context = null;
        instance.element.style.display = 'none';
        // Another option is to remove the visibility class
    }

    // Click events for menu items (useful if the menu involves more than just simple links)
    instance.menuItem1Click = function(e) {
         // Customize actions here
         instance.close();
         // Call this at the end of each menu item's click event handler
    }

    // ... Include additional click event handlers for other menu items (one per item)

    return instance;
}

// Instantiate your menu object somewhere in your 'document ready' script or during grid initiation
var menu = new gridMenu("#my_awesome_floating_menu");

This snippet demonstrates how to handle click events for links inside the grid:

function cellLinkClick(event) {
    var context = {}; // Prepare any necessary data to send to the menu
    menu.open(event, context);
}

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

Fetch data using Ajax without the need for a hash signal

My current goal is to load content through Ajax on a website. Let's say our main page is example.com/blankpage (I've eliminated the .html extension using htaccess). At the moment, I have it set up so that when a link on the page directs to mysite ...

executing a Prisma database migration with various schemas

I am currently immersed in a Prisma project where my goal is to create a node module that can be utilized by other projects. The challenge now is to ensure that the database stays synchronized with the models and the primary project, so all testing platfor ...

What causes the issue of undefined destructured environment variables in Next.js?

Within my application built with Next.js, I have configured a .env file containing a variable labeled API_KEY. When attempting to destructure the value of this variable, I am consistently met with undefined, as shown below: const { API_KEY } = process.env ...

Using Backbone.js to Retrieve Data from the Server and Bind it to a Model

Having recently delved into Backbone.js, I found this informative tutorial quite helpful in getting started. Now, I am looking to take things a step further by fetching data from the server instead of hardcoding values in JavaScript as demonstrated in the ...

Display all items with pagination in a Material UI Table using React

I have recently implemented pagination in a react data table to handle a large number of entries. I wanted to add an option to display all entries by selecting "all" in the rowsPerPageOptions dropdown menu. Currently, I am able to show the count of all ent ...

Executing a mousedown event in Ajax while simultaneously running another JavaScript function using JQuery

One issue I am facing involves a JavaScript method. There is a date slider for months that triggers an AJAX call when the month is changed (mouseup event). Within this AJAX call, there is another JavaScript code ($.blockUI) which seems to interfere with th ...

Creating CSS-style overlayed images that are resizable

I have a collection of images all the same size, and I want them to be overlaid on top of each other. I've tried setting the position of the images to absolute, but this causes an issue with the container not adjusting its size accordingly. Additiona ...

Interacting with Cassandra using PHP

I am attempting to execute a SELECT query from the Cassandra Database using a PHP script. The connection is successfully established through PHP. Here is the query: $session = $cluster->connect($keyspace); $result = $session->execute("SELEC ...

Obtain the AngularJS service using Vanilla JavaScript

Trying to access the AngularJS service from plain JavaScript. Utilizing the following syntax: angular.injector(['ng', 'error-handling']).get("messagingService").GetName(); It works fine when the messagingservice has no dependencies. H ...

Problem with the menu button overflowing

I'm exploring the process of designing burger menus for the mobile version of my site. I've successfully created a basic burger menu with some JavaScript assistance, but I encountered an overflow issue. The burger menu functions properly, but the ...

What is the process for closing the side menu by clicking on the dark area?

I created a basic side navigation menu. When you resize the window to a smaller size, a red square will appear. If you click on this red square, the menu will open. The menu opens correctly, but I want it to close when I click on the dark area instead of ...

Step-by-step guide on inserting a variable into .doc() to create a new table

Recently, I created a SignIn page that uses variables to store data fetched with document.getElementByClassName. Now, I am facing an issue while trying to create a new document on Firebase using the person's name stored in a variable. Struggling with ...

Tips for Creating a Fixed-Width Element

I am struggling with creating text wrapping around a box inside a full width page template on Wordpress. The plugin developer suggested wrapping the text inside a fixed width element, but I am unsure how to do this. Any assistance would be greatly apprecia ...

Freshening up the data source in a Bootstrap Typeahead using JavaScript

I'm trying to create a dropdown menu that displays options from an array stored in a file called companyinfo.js, which I retrieve using ajax. The dropDownList() function is called when the page loads. function dropDownList (evt) { console.log("dr ...

Sending arrays in JSON format using Node.js Express (res.json)

I have a code snippet like this: app.get('/orders/:pizzeriaID/:status', async (req, res) => { try { const requestedOrderByPizzeriaID = req.params['pizzeriaID']; const requestedOrderByStatus = req.params['status']; ...

Modifying the values of array elements in MongoDB

I am currently attempting to modify specific elements within an array. This particular array consists of objects that have two distinct fields. The displayed output from my view is as follows: Each line in the display corresponds to the index of the objec ...

Access to this page via the Odesk API in node.js is restricted and unauthorized

/** * Here is an example of how to use the oDeskAPI * * @package oDeskAPI * @since 09/22/2014 * @copyright Copyright 2014(c) oDesk.com * @author Maksym Novozhylov <<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data ...

Can you combine multiple user validation rules with express-validator?

I have a set of rules that are almost similar, except for one where the parameter is optional and the other where it is mandatory. I need to consolidate them so that I can interchangeably use a single code for both cases. Is there a way to merge these rul ...

Save a customized JavaScript file and integrate it into a Vue component

As a newcomer to Vue.js, I have a question regarding calling functions from a custom JavaScript file within a Vue component. Here is what I attempted: custom.js class API{ function testCall(){ alert("test ok"); } } export {API} App.vue ...

Issue with TypeORM @BeforeInsert causing a field in Entity not to be populated with value

Currently, I am facing an issue where I am attempting to update or insert into a token field before the record is saved. However, when utilizing the @BeforeInsert hook, I encounter the following error: "error": "Cannot read property 'co ...