Code Monkey home page Code Monkey logo

Comments (5)

cherniavskii avatar cherniavskii commented on June 30, 2024

Hi @yashwant-raut
Interesting use case!
Overall, your approach makes sense to me!
A few comments from me:

  1. Using React context works just fine here. A bit simpler solution would be to use a pubsub pattern for communication between the grids.
    For example, using mitt():

    const emitter = mitt();
    
    // Send the selected rows in grid 1
    emitter.emit('moveRows', { rows });
    
    // Receive the selected rows in grid 2
    React.useEffect(() => {
        const onMoveRows = ({ rows }) =>  {
    	  // ...
    	};
    	emitter.on('moveRows', onMoveRows);
    	return () => emitter.off('moveRows', onMoveRows);
    })
  2. You have to make sure you don't have duplicated row ids, which is currently the case in the linked demo:

from mui-x.

yashwant-raut avatar yashwant-raut commented on June 30, 2024

@cherniavskii Thanks for going thorugh codesandbox and my question.
I have never heard about pubsub pattern for communication between the grids. Thanks for giving me context.
I will go through this and try to implement pubsub pattern. It would be great if you could point me to a link to a hosted example where this pattern is used in MUI datagrid.

"You have to make sure you don't have duplicated row ids, which is currently the case in the linked demo:
"
yes for that part I am thinking about creating a dynamic GUID and assign to the rows.

MUI has this method updateRows
"Is it more appropriate to use this method instead of what I have already done?" does this have more performance benefits?
I am going to handle a large dataset in Grid.

Again thanks for the help.

from mui-x.

michelengelen avatar michelengelen commented on June 30, 2024

@cherniavskii Thanks for going thorugh codesandbox and my question. I have never heard about pubsub pattern for communication between the grids. Thanks for giving me context. I will go through this and try to implement pubsub pattern. It would be great if you could point me to a link to a hosted example where this pattern is used in MUI datagrid.

The pubsub pattern is nothing we came up with, but a software design pattern that can be used in a multitude of ways. Here is a basic overview of the pattern explained: Pub/Sub Pattern. In your case both grids could be publishing and subscribing to the events to allow for a bidirectional interaction

"You have to make sure you don't have duplicated row ids, which is currently the case in the linked demo: " yes for that part I am thinking about creating a dynamic GUID and assign to the rows.

👍

MUI has this method updateRows "Is it more appropriate to use this method instead of what I have already done?" does this have more performance benefits? I am going to handle a large dataset in Grid.

Since updateRows can be used to update a subset of rows it certainly has perf benefits.

from mui-x.

yashwant-raut avatar yashwant-raut commented on June 30, 2024

@michelengelen thanks for the reply will try to implement this way.

from mui-x.

github-actions avatar github-actions commented on June 30, 2024

⚠️ 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 @yashwant-raut?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

from mui-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.