简体   繁体   English

mui 数据表无法读取未定义的属性(读取“下载”)

[英]mui datatable Cannot read properties of undefined (reading 'download')

["

I'm using "react": "^17.0.2",<\/code> and "mui-datatables": "^4.2.2",<\/code><\/i>我正在使用"react": "^17.0.2",<\/code>和"mui-datatables": "^4.2.2",<\/code><\/b><\/p>

I need to download ( export ) data that is not displayed in the datable .<\/i>我需要下载(导出)数据表中未显示的数据。<\/b><\/p>

This is a part of my code :<\/i>这是我的代码的一部分:<\/b><\/p>

    [
    // ..... other columns
    {
      label: "Détail IIG",
      name: "reference",
      options: {
        download: false,
        customBodyRender: (value) => {
          if (currentUserId === value.user.id) {
            if (value.calculated) {
              return (
                <Tooltip title="les résultats IIG de votre dossier sont disponibles">
                  <Link
                    className="custom-green-iig-link"
                    to={`/${value.slug}/project/iig`}
                  >
                    <FontAwesomeComponent
                      icon={faEye}
                      size="lg"
                      color="white"
                    />
                  </Link>
                </Tooltip>
              );
            } else {
              return null;
            }
          } else {
            if (value.calculated) {
              return (
                <Tooltip title="Les résultats IIG de ce dossier sont disponibles">
                  <Link
                    className="custom-green-iig-link"
                    to={`/${value.slug}/project/iig`}
                  >
                    <FontAwesomeComponent
                      icon={faEye}
                      size="lg"
                      color="white"
                    />
                  </Link>
                </Tooltip>
              );
            } else {
              return null;
            }
          }
        },
        setCellHeaderProps: (value) => ({
          style: {
            fontWeight: "bold",
            textAlign: "center",
            whiteSpace: "nowrap",
          },
        }),
        setCellProps: (value) => ({
          style: {
            textAlign: "center",
          },
        }),
      },
    },
    {
      name: "pilierE",
      options: {
        empty: false,
        download: true,
        filter: false,
        sort: false,
        display: false,
        viewColumns: false,
      },
    },
  ];
I fix the problem, i have filterOptions like this , so i set useDisplayedColumnsOnly and useDisplayedRowsOnly to true instead of false

  downloadOptions: {
          filename: "IIG-EXPORT.csv",
          separator: ";",
          filterOptions: {
            useDisplayedColumnsOnly: false, // it was true
            useDisplayedRowsOnly: false, // it was true
          },
        },

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM