title: Material UI DataGrid: Button to Delete Individual Row
body: <p>I am making a React component using MaterialUI, that uses a Datagrid to store a queue of files. It looks like this:
  <a href="https://i.stack.imgur.com/oh0GH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oh0GH.png" alt="enter image description here" /></a></p>
  <p>So one feature I am trying to work on right now is where when the user clicks those three dots at the end of each row, a Menu (with one item) comes up that says &quot;Delete&quot; which can be used to delete that respective row.  I'm having some trouble righting up the code for that. So this is the code I have for it:</p>
  <pre><code>const columns: GridColDef[] = [
        {
          field: 'filename',
          headerName: 'File Name',
          width: 350,
          editable: true,
        },
        {
          field: 'size',
          headerName: 'Size',
          width: 120,
          editable: true,
        },
        {
          field: 'date',
          headerName: 'Date',
          width: 120,
          editable: true,
        },
        {
            field: &quot;&quot;,
            headerName: &quot;&quot;,
            sortable: false,
            width: 80,
            disableClickEventBubbling: true,
            renderCell: (params) =&gt; {
              const handleDropdown = (event) =&gt; {
                  setAnchorEl(event.currentTarget);
              }
              const handleClose = () =&gt; {
                  setAnchorEl(null);
              };
              return(
                  &lt;div&gt;
                      &lt;IconButton
                         aria-label=&quot;more&quot;
                         aria-controls=&quot;long-menu&quot;
                         aria-haspopup=&quot;true&quot;
                         onClick={handleDropdown}
                       &gt;
                         &lt;MoreHorizIcon /&gt;
                      &lt;/IconButton&gt;
                      &lt;Menu
                           id=&quot;fade-menu&quot;
                           anchorEl={anchorEl}
                           keepMounted
                           open={open}
                           onClose={handleClose}
                       &gt;
                           &lt;MenuItem id={$(`params.id`)} onClick={() =&gt; deleteFile(params)}&gt;Delete&lt;/MenuItem&gt;
                      &lt;/Menu&gt;
                   &lt;/div&gt;
                 );
            }
        }
      ];
  
  const deleteFile = (params) =&gt; {
          console.log(params);
  };
  </code></pre>
  <p>So within the MenuItem, I have it map to the function &quot;deleteFile&quot; when the user clicks on it, and I pass in &quot;params.&quot; What I am trying to do i use the &quot;id&quot; number that is in params to set my state variable accordingly, but the problem I am having is that my params all end up being the same.</p>
  <p>For reference, here is an example of how params would look like (i blurred out the filename):
  <a href="https://i.stack.imgur.com/MA2K5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MA2K5.png" alt="enter image description here" /></a></p>
  <p>What I mean by this is, if I have for example 6 files uploaded in the UI, the params all have the exact same id number, and the filename ends up being the name of the file that was the last one to upload. So in other words, I am passing in the exact same file object no matter what row I select. I'm not sure why this is happening, because I thought the &quot;params&quot; should vary depending on which row you select. Any ideas?</p>