Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[data grid] Uploading files to mui x datagrid making it understand that cell is updated after file upload #12011

Closed
catdalf opened this issue Feb 9, 2024 · 6 comments
Labels
component: data grid This is the name of the generic UI component, not the React module!

Comments

@catdalf
Copy link

catdalf commented Feb 9, 2024

I have 2 columns that are for file upload. I have used
const FileUploadCell = ({ onChange, field, id }) => (
<input type="file" onChange={(event) => onChange(event, field, id)} name={field} accept=".pdf, .doc, .docx, .xls, .xlsx, .csv" required />
);
this const to assign it to columns. Under my fields i use
renderCell: (params) =>

this code to create a custom cell which is for file uploading. However row never gets updated after i make the file upload. I also need to save this file to database but since the row does not even recognize this change in react side i also can not send it to backend side to save it to database.

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 9, 2024
@zannager zannager added the component: data grid This is the name of the generic UI component, not the React module! label Feb 9, 2024
@michelengelen
Copy link
Member

Please provide a minimal reproduction test case with the latest version. This would help a lot 👷.

A live example would be perfect. You can find a examples and guides on how to find templates in our docs with which you can provide examples for your specific use-case: Support - Bug reproduction.

Thank you! 🙇🏼

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 12, 2024
@michelengelen michelengelen changed the title Uploading files to mui x datagrid making it understand that cell is updated after file upload [data grid] Uploading files to mui x datagrid making it understand that cell is updated after file upload Feb 12, 2024
@catdalf
Copy link
Author

catdalf commented Feb 13, 2024

I guess i have solved this via this code:

const handleFileChange = (event, params, field) => {
  event.persist();
  const file = event.target.files[0];
  console.log('File changed:', file);

  
  params.api.updateRows([{ id: params.id, [field]: file }]);
};

{
          field: 'datasheet',
          headerName: 'Datasheet',
          width: 150,
          headerAlign: 'center',
          renderCell: (params) => {
            return (
              <input
                type="file"
                onChange={(event) => handleFileChange(event, params, 'Datasheet')}
                name="Datasheet"
                accept=".pdf, .doc, .docx, .xls, .xlsx, .csv"
                required
              />
            );
          },
        },

now when i upload the file in cell i can see that row is being updated. Previously the value i see related to datasheet column was this -> "" now i can see the file related properties.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Feb 13, 2024
@michelengelen
Copy link
Member

Great! Is this resolved for you now?

@michelengelen michelengelen added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 13, 2024
@catdalf
Copy link
Author

catdalf commented Feb 14, 2024

I guess it is resolved. However can i ask something related to pagination?
I know that in MIT version one page can hold at most 100 rows. How about when it comes to number of pages? Can i have unlimited number of pages in my mui x datagrid?

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Feb 14, 2024
@zannager zannager removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 15, 2024
@michelengelen
Copy link
Member

I guess it is resolved. However can i ask something related to pagination? I know that in MIT version one page can hold at most 100 rows. How about when it comes to number of pages? Can i have unlimited number of pages in my mui x datagrid?

Yes, there are no limitations on the number of pages afaik.

Since the original issue is resolved I will close this now. Thanks! 🙇🏼

Copy link

⚠️ This issue has been closed.
If you have a similar problem, please open a new issue and provide details about your specific problem.
If you can provide additional information related to this topic that could help future readers, please feel free to leave a comment.

How did we do @catdalf?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants