nick-keller / react-datasheet-grid

An Airtable-like / Excel-like component to create beautiful spreadsheets.
MIT License
1.81k stars 170 forks source link

render Button depending on row data #360

Closed matsunotsuma closed 2 months ago

matsunotsuma commented 2 months ago

Hi, I want to render various button depending on row data. So I wrote this code.

const columns = [
/*...*/
{
      ...keyColumn("action", {
        component: ({ rowData }) => {
          if (rowData.defaultUser) {
            return null;
          } else if (rowData.status === "active") {
            return <Button>削除</Button>;
          } else if (rowData.status === "inactive") {
            return <Button>追加</Button>;
          }
          console.log("rowData", rowData);
          return <Button>test</Button>;
        },
      }),
      title: "",
    },]

But this code doesn't work because "rowData" is undefined. Why undefined?

Best regards.

matsunotsuma commented 2 months ago

i found that "rowData" contains only target column data.