Having trouble with the filtering feature in Material UI Datagrid

I'm currently using Material UI Data Grid to display a table on my website. The grid has an additional filter for each column, but when I click on the filter, it hides behind my Bootstrap Modal. Is there a way to bring it to the front?

https://i.stack.imgur.com/m9N0k.png

Below is the code snippet for the DataGrid inside the Modal:

<Modal show={this.state.menu} dialogClassName='modal-width'>
    <div class='modal-content modal inmodal'>
        <Modal.Header>
            <Modal.Title></Modal.Title>
        </Modal.Header>
        <Modal.Body class='modal-body'>
            {HCPTable}
        </Modal.Body>

This is the section of HCP table variable that contains the Data Grid. Various if conditions are used to determine its visibility:

HCPTable = 
    <div class='row' style={{ marginTop: '15px' }}>
        <div style={{ height: 400, width: '100%' }}>
            <DataGrid
                rows={this.state.advancedSearchResults} columns={columns} pageSize={5}
                onRowSelected={(rowSelection) => {
                    this.setState({
                        selectedRow: rowSelection.data,
                        HCPSelected: new Array(String('[' + rowSelection.data.npi + ']'))
                    }, () => {
                        let HCPSelected = new Array(String('[' + rowSelection.data.npi + ']'))
                        console.log(HCPSelected);
                        console.log(typeof(HCPSelected));
                        console.log('state inside DataGrid: ',this.state);
                    })
                }}
            />
        </div>
    </div>

I would like the filter dropdown to appear in front instead of behind. Adjusting the z-index in the mentioned class makes it visible, but I am unsure how to make this change permanent within my application.

Edit:

After some trial and error, I discovered that changing the z-index in the console brings the filter to the front. The specific class where the change was made is linked here:

https://i.stack.imgur.com/MbxfH.png

How can I access this class within my application to ensure the desired visibility at all times?

Edit2:

Shown below is a screenshot depicting the issue I aim to resolve:

https://i.stack.imgur.com/WFzG6.png

Answer №1

To customize the styling for this class, you can utilize the customization options of a component:


const useStyles() = makeStyles((theme) => ({
    root: {
        z-index: 500,
    }
}))

const yourComponent = () => {
    const classes = useStyles();
    return (
        <DataGrid
            ...
            classes={{
                root: classes.root
            }}
        />
    );
}

If you need to overwrite specific styles, here is a comprehensive list of available classes for the DataGrid component that you can target within your root class: https://material-ui.com/api/data-grid/#css

For instance, if you want the cells to be displayed in red color:

You should include the following code in your root object:


const useStyles() = makeStyles((theme) => ({
    root: {
        z-index: 500,
        '& .MuiDataGrid-cell': {
            color: 'red',
        },
    }
}))

Answer №2

After some trial and error, I managed to solve the issue by making modifications in the App.js file. Firstly, I imported StylesProvider and then added the materialStyles.css file.

   import { StylesProvider } from "@material-ui/core/styles";
   import './materialStyles.css';

    class App extends Component {

    render() {
return (
  <StylesProvider injectFirst>
  <div>
    <Layout />
  </div>
  </StylesProvider>
)
  }
  }

The contents of materialstyless.css are:

    .MuiDataGridMenu-root {
z-index: 3000
    }

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

Execute HTML and JS files through Eclipse PDT to view in a web browser

Is it possible to open HTML and JS files in a web browser within Eclipse PDT? Right now, only PHP files seem to launch successfully, otherwise an "Unable to Launch" dialog pops up. Any advice is appreciated! ...

Ensuring payload integrity using microrouter: A step-by-step guide

I have utilized this code to develop a microservice const { json, send } = require('micro') const { router, post } = require('microrouter') const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY) console.log(process.e ...

Using style binding and ngStyle doesn't appear to be effective for setting a background image within a DIV element in Angular5

After facing difficulties in customizing the spacing of Angular material cards, I decided to create my own cards. However, during this process, I encountered an issue where I needed to set an image as a background inside a div. Despite trying various CSS ...

Struggling to showcase JSON information, encountering a JSON Parsing issue

I'm currently facing an issue with displaying JSON data on my screen, specifically the integer 4. Unfortunately, I keep encountering a JSON Parse Error whenever I try to retrieve and show the data. Even though the data appears to be successfully pos ...

Using ng-repeat with deeply nested objects

I am facing an issue with rendering an object that contains comments along with replies objects that have nested replies objects. I attempted to use a solution from here, but it resulted in my replies object being undefined. For example, I tried the follow ...

What are the reasons behind the compilation failure of the react-sortable-hoc basic example when using typescript?

Take a look at this sample code snippet extracted from the official react-sortable-hoc webpage. import React, {Component} from 'react'; ... // Code snippet goes here ... render(<SortableComponent/& ...

Styling the <Autocomplete/> component in Material UI with React to achieve rounded corners

Google's search bar has always been a favorite of mine, with its rounded corners and generous text padding. https://i.stack.imgur.com/UbKrr.png I'm attempting to replicate this aesthetic using Material UI's <Autocomplete/> component ...

A loop variable in Javascript is a function that iterates

var x = 99; while (true) { function lyrics(person) { return x + " " + "lines of code in the file " + x + " " + person + (x-1) + " lines of code" + "!"; } console.log(lyrics("John strikes one out, clears it all out ;")); x -= 1; if (x ...

Troubleshooting steps for resolving Heroku's "State changed from up to crashed" error caused by Mongoose connection issue

I am encountering an issue while deploying my Node.js/MongoDB app to Heroku. It crashes with the following error: MongooseServerSelectionError: connection <monitor> to 104.155.184.217:27017 closed Below are excerpts from my log: 2022-07-10T23:36:17. ...

What is the best way to dynamically update a specific value within an object based on the current state in React/Next?

I have implemented a Context API where an object is set, and when the user clicks, the state changes. I need to update a specific value with the new state value. const initialState = { notification: false, setting: false, profile: false, } exp ...

Adjusting various settings on breakpoints in MUI v5

Previously in MUI version 4, I was able to apply multiple style parameters within a single media query using the following code: [theme.breakpoints.up('xs')]: { width: 100px, color: green, }, [theme.breakpoints.up('md' ...

The SharePoint 2010 standard model dialogs seamlessly blend transparent printing with the background content

When using Sharepoint 2010, each list item you edit will open in a new modal dialog box by default. This dialog box appears as a new div with the class of ms-dlgContent. It also creates a div with the class of ms-dlgOverlay which acts as a grey overlay di ...

Converting data from a JSON-like file format into valid JSON using JavaScript

I have a unique situation where I am dealing with numerous files that have an unusual file extension. My goal is to utilize JavaScript to read these files and then convert their contents into either JSON or regular JavaScript objects. Is this task even fe ...

Theming for Atom and Electron developer tools

After switching from the netbeans IDE to github's atom, I realized that some necessary features were missing. Unable to find a suitable package, I decided to try customizing it myself, gaining valuable insight into the editor in the process. However, ...

I obtained the binary tree output in the form of an object. How can I extract the values from this object and store them in an array to continue working on

Issue Statement In this scenario, you have been presented with a tree consisting of N nodes that are rooted at 1. Each node in the tree is associated with a special number, Se. Moreover, each node possesses a certain Power, which is determined by the count ...

Avoiding repetition in json array using reactjs with the help of axios

After receiving guidance from @Akrion, I managed to resolve the issue! Check out my comments below our conversation for the solution. I am relatively new to reactJS and axios, but I recently collaborated with a classmate on a project. Now, I find myself s ...

Failed commitments in Protractor/WebDriverJS

WebdriverIO and Protractor are built on the concept of promises: Both WebdriverIO (and as a result, Protractor) APIs operate asynchronously. All functions return promises. WebdriverIO maintains a queue of pending promises known as the control flow to ...

Creating a custom component in Angular 2 that includes several input fields is a valuable skill to have

I have successfully created a custom component in Angular 2 by implementing the CustomValueAccessor interface. This component, such as the Postcode component, consists of just one input field. <postcode label="Post Code" cssClass="form-control" formCon ...

Images are suddenly encircled by a mysterious border

On my wordpress website, I encountered a strange issue with some photos. Specifically, an image of a cross in a circle is getting a weird border around it, but only on certain resolutions (such as width:1506). Despite inspecting the element, I couldn' ...

``After initialization, the service is unable to retrieve the object as

I have a special service that stores specific objects to be shared among different controllers. Here is an example of the code I am using: $rootScope.$on('controller.event', function(event, arg){ self.backendConnectorService.getBac ...