gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

MUIDataTableToolbar-root @media print setting might have negative impact on printing of table? #1370

Open william-chu opened 4 years ago

william-chu commented 4 years ago

image

Expected Behavior

This area should render in print outs, if I'm not mistaken the toolbar has a left and right side and the left is reserved for the table's title?

Current Behavior

The display none is applied to the MUIDataTableToolbar so the @media print change is making the table render without a title section. I can understand not wanting to see the actions menu, if that is the case I would suggest applying the css to those sections and do visibility hidden rather than display none since visibility will persist the empty space.

Tech Version
Material-UI 4.9.1
MUI-datatables 3.0.1
patorjk commented 4 years ago

This is one of those issues where there seems to be a lot of disagreement. Several people wanted it removed for printing, so it was removed for printing in v3. However, it can be added back in with some theme overrides:

https://codesandbox.io/s/muidatatables-custom-toolbar-rygee?file=/index.js

let defaultTheme = createMuiTheme();

let getMuiTheme = () =>
  createMuiTheme({
    overrides: {
      MUIDataTableToolbar: {
        root: {
          "@media print": {
            display: "block !important"
          }
        },
        [defaultTheme.breakpoints.down("xs")]: {
          root: {
            "@media print": {
              display: "block !important"
            }
          }
        }
      }
    }
  });
william-chu commented 4 years ago

Thanks for the info! I can see that desire since it's probably a pretty common scenario, but I always think removal of something should require people to make the customization themselves rather than making it a default. I was confused since I have a print preview mode which allows the user to view what the table would look like if they were to convert it into a pdf. I expect to see what I have rendered in print mode unless I tell it to do otherwise.

Also, am I incorrect in that the table title is injected into the left side of the toolbar? If so, wouldn't the table title be something people need to see in the printout? If that is the case, maybe it would be the actions/filter in the table toolbar that are display none in print mode? Sorry I can't remember if I made that change myself since there are so many adjustments in my table.

I can reverse override this with the given info. Appreciate it!