Giter Site home page Giter Site logo

Comments (8)

nkoterba avatar nkoterba commented on May 24, 2024 3

@ceolter Although this issue is closed, I was trying to determine the best way to handle my use case:

I have updated row data for a specific row from the backend server. I'd like to just update the row's data and call api.refreshRows([rowToRefresh]).

However, the only way to locate the row is to call api.forEachNode and find the matching node with id. However, once I find the correct row I can't event short circuit the forEachNode with a break statement like a normal javascript array forEach.

Do you still recommend just maintaining our own map to find rows based on Ids or is there another more clever way to just find a row based on it's id?

Thanks!

from ag-grid-enterprise.

ceolter avatar ceolter commented on May 24, 2024

i assume you are talking about cellRenderer? if yes, then node is passed as a param, and the id is in the node.

another way, which i don't recommend, but you might want, is to also use api.getBusinessKeyForNode(), that will put the id you give it into the DOM as an attribute to the row. you don't have to have it the same as the node id, but you can do if you decide.

from ag-grid-enterprise.

dephiros avatar dephiros commented on May 24, 2024

@ceolter I have the node id and want to get the node outside of the cellRenderer context. I would like a more efficient way to get the node object(maybe getNodeFromId in the gridApi) without having to use forEachNode and go through all the nodes. Is it possible or could it be implemented?

from ag-grid-enterprise.

ceolter avatar ceolter commented on May 24, 2024

nope - the only collection the grid has of the nodes is in the rowModel, which just keeps the nodes in a list. if you want to index by id, then i suggest you keep a map yourself? the grid doens't need it, so it's not a grid responsibility. given you are providing the nodeId's, then you have the perfect callback getRowNodeId for populating your map.

from ag-grid-enterprise.

ceolter avatar ceolter commented on May 24, 2024

because the grid doesn't need it, it would be a wast of memory for the grid to keep such a map, given very few people (only one so far) has asked for it :)

from ag-grid-enterprise.

dephiros avatar dephiros commented on May 24, 2024

got it. Thank you for the response :). I will keep a node reference with my custom checkbox for now

from ag-grid-enterprise.

a497988 avatar a497988 commented on May 24, 2024

+1

from ag-grid-enterprise.

shijusn avatar shijusn commented on May 24, 2024

Is there a way to early exit/break from forEachNode loop once we find a satisfying node?
return statement doesn't work inside forEachNode()

from ag-grid-enterprise.

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.