{
    "componentChunkName": "component---src-templates-doc-page-jsx",
    "path": "/javascript-data-grid/accessing-data/",
    "result": {"data":{"markdownRemark":{"htmlAst":{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This section covers the ways data can be accessed once it has been supplied to the grid."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each time you pass data to the grid, the grid wraps each data item with a "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/row-object/"},"children":[{"type":"text","value":"Row Node"}]},{"type":"text","value":" object. For example, if your data has 20 rows, the grid creates 20 Row Node objects, each Row Node wrapping one item of your data."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"It is sometimes handy to access these Row Nodes. One example where it is handy is if you want to select a row, you can call "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"rowNode.setSelected(true)"}]},{"type":"text","value":" to select it. This section details the different ways a Row Node can be accessed."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The following methods are provided for accessing the individual Row Nodes. A deeper explanation of these methods, along with examples, is provided further down."}]},{"type":"element","tagName":"h2","properties":{"id":"accessing-row-node-api-methods","style":"position:relative;"},"children":[{"type":"text","value":"Accessing Row Node API Methods"},{"type":"element","tagName":"a","properties":{"href":"#accessing-row-node-api-methods","ariaLabel":"accessing row node api methods permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"api-documentation","properties":{"source":"grid-api/api.json","section":"rowNodes"},"children":[]}]},{"type":"element","tagName":"h2","properties":{"id":"accessing-rows-by-row-id","style":"position:relative;"},"children":[{"type":"text","value":"Accessing Rows by Row ID"},{"type":"element","tagName":"a","properties":{"href":"#accessing-rows-by-row-id","ariaLabel":"accessing rows by row id permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The easiest way to get a Row Node is by its Row ID. The ID is either provided by you using the grid callback "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowId()"}]},{"type":"text","value":", or generated by the grid using an internal sequence."}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\nconst gridOptions = {\n    // callback tells the grid to use the 'id' attribute for IDs, IDs should always be strings\n    getRowId: params => params.data.id\n}\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"To lookup a Row Node use "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowNode()"}]},{"type":"text","value":" on the Grid API as follows:"}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\n| // get the row node with ID 55\n| const rowNode = gridOptions.api.getRowNode('55');\n|\n| // do something with the row, e.g. select it\n| rowNode.setSelected(true);\n"}]},{"type":"element","tagName":"h2","properties":{"id":"iterating-rows","style":"position:relative;"},"children":[{"type":"text","value":"Iterating Rows"},{"type":"element","tagName":"a","properties":{"href":"#iterating-rows","ariaLabel":"iterating rows permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Sometimes you may want to iterate through all the Row Nodes in the grid. This can be done using the grid's iteration APIs. The iteration APIs go through every Row Node, regardless of whether the Row Node is displayed or not. For example, if grouping and the group is closed, the group's children are not displayed by the grid, however the children are included in the iteration 'for-each' methods."}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\n| // iterate through every node in the grid\n| gridOptions.api.forEachNode((rowNode, index) => {\n|     console.log('node ' + rowNode.data.athlete + ' is in the grid');\n| });\n|\n| // iterate only nodes that pass the filter\n| gridOptions.api.forEachNodeAfterFilter((rowNode, index) => {\n|     console.log('node ' + rowNode.data.athlete + ' passes the filter');\n| });\n|\n| // iterate only nodes that pass the filter and ordered by the sort order\n| gridOptions.api.forEachNodeAfterFilterAndSort((rowNode, index) => {\n|     console.log('node ' + rowNode.data.athlete + ' passes the filter and is in this order');\n| });\n|\n| // iterate through every leaf node in the grid\n| gridOptions.api.forEachLeafNode((rowNode, index) => {\n|     console.log('node ' + rowNode.data.athlete + ' is not a group!');\n| });\n"}]},{"type":"element","tagName":"div","properties":{"className":["custom-block","note"]},"children":[{"type":"element","tagName":"div","properties":{"className":["custom-block-body"]},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"All the methods above work with the Client-Side Row Model, i.e. the default "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/row-models/"},"children":[{"type":"text","value":"Row Model"}]},{"type":"text","value":".\nFor all the other row models (i.e. "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/viewport/"},"children":[{"type":"text","value":"Viewport"}]},{"type":"text","value":",\n"},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/infinite-scrolling/"},"children":[{"type":"text","value":"Infinite"}]},{"type":"text","value":" and "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.5/server-side-model/"},"children":[{"type":"text","value":"Server-Side"}]},{"type":"text","value":") the only method\nthat is supported is "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"api.forEachNode()"}]},{"type":"text","value":" and that will return back Row Nodes that are loaded into\nbrowser memory only (as each of these row models use a data source to lazy load rows)."}]}]}]},{"type":"element","tagName":"h2","properties":{"id":"example-using-for-each-methods","style":"position:relative;"},"children":[{"type":"text","value":"Example Using For-Each Methods"},{"type":"element","tagName":"a","properties":{"href":"#example-using-for-each-methods","ariaLabel":"example using for each methods permalink","className":["docs-header-icon","after"]},"children":[{"type":"element","tagName":"svg","properties":{"id":"icon","xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 32 32"},"children":[{"type":"element","tagName":"path","properties":{"d":"M29.25,6.76a6,6,0,0,0-8.5,0l1.42,1.42a4,4,0,1,1,5.67,5.67l-8,8a4,4,0,1,1-5.67-5.66l1.41-1.42-1.41-1.42-1.42,1.42a6,6,0,0,0,0,8.5A6,6,0,0,0,17,25a6,6,0,0,0,4.27-1.76l8-8A6,6,0,0,0,29.25,6.76Z"},"children":[]},{"type":"element","tagName":"path","properties":{"d":"M4.19,24.82a4,4,0,0,1,0-5.67l8-8a4,4,0,0,1,5.67,0A3.94,3.94,0,0,1,19,14a4,4,0,0,1-1.17,2.85L15.71,19l1.42,1.42,2.12-2.12a6,6,0,0,0-8.51-8.51l-8,8a6,6,0,0,0,0,8.51A6,6,0,0,0,7,28a6.07,6.07,0,0,0,4.28-1.76L9.86,24.82A4,4,0,0,1,4.19,24.82Z"},"children":[]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The example below shows the different For-Each API methods as follows:"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"For-Each Node"}]},{"type":"text","value":": Prints out every row in the grid. It ignores filtering and sorting."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"For-Each Node After Filter"}]},{"type":"text","value":": Prints out every row in the grid, except those filtered out."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"For-Each Node After Filter and Sort"}]},{"type":"text","value":": Prints out every row in the grid, except those filtered,\nand in the same order they appear on the screen if sorting is applied."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"strong","properties":{},"children":[{"type":"text","value":"For-Each Leaf Node"}]},{"type":"text","value":": Prints out every row in the grid except group rows."}]},{"type":"text","value":"\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"In the example, try applying some sorts and filters, and see how this impacts the different operations."}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"grid-example","properties":{"title":"Using For-Each","name":"using-for-each","type":"generated","options":"{ \"enterprise\": true, \"modules\": [\"clientside\",  \"menu\", \"setfilter\", \"rowgrouping\"], \"exampleHeight\": 590 }"},"children":[]}]}]},"frontmatter":{"title":"Accessing Client-Side Data","version":null,"enterprise":null,"sideMenu":null,"description":null},"headings":[{"id":"accessing-row-node-api-methods","depth":2,"value":"Accessing Row Node API Methods"},{"id":"accessing-rows-by-row-id","depth":2,"value":"Accessing Rows by Row ID"},{"id":"iterating-rows","depth":2,"value":"Iterating Rows"},{"id":"example-using-for-each-methods","depth":2,"value":"Example Using For-Each Methods"}]}},"pageContext":{"frameworks":["javascript","react","angular","vue"],"framework":"javascript","srcPath":"/accessing-data","pageName":"accessing-data"}},
    "staticQueryHashes": ["1766026005","699667431","940729948"]}