{
    "componentChunkName": "component---src-templates-doc-page-jsx",
    "path": "/javascript-data-grid/row-ids/",
    "result": {"data":{"markdownRemark":{"htmlAst":{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"This section explains how the grid assigns row IDs and shows how applications can supply custom row IDs.  "}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Each grid row has a unique row ID which is used by the grid to identify rows, e.g. for identifying what\nrows are currently selected. These row IDs can be "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.1/row-ids/#grid-assigned-ids"},"children":[{"type":"text","value":"Grid Assigned"}]},{"type":"text","value":" or\n"},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.1/row-ids/#application-assigned-ids"},"children":[{"type":"text","value":"Application Assigned"}]},{"type":"text","value":".   "}]},{"type":"element","tagName":"h2","properties":{"id":"grid-assigned-ids","style":"position:relative;"},"children":[{"type":"text","value":"Grid Assigned IDs"},{"type":"element","tagName":"a","properties":{"href":"#grid-assigned-ids","ariaLabel":"grid assigned ids 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":"Row IDs are generated by the grid when data is supplied to the grid. The grid uses a sequence starting at 0 and\nincrementing by 1 to assign row IDs, so for example if there are three rows they will have IDs of "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"0"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"1"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"2"}]},{"type":"text","value":".\nThe row ID does not change for a row once it is set."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"If the row data is updated to a new set, the grid will continue with its sequence. For example if 10 rows are initially\nset, IDs [0..9] are used. Then, if the data is set again for another 10 rows, IDs [10..19] are used. This is true even if\nthe second set of rows are logically identical to the first set of rows (i.e. it's a refresh operation)."}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.1/grouping/"},"children":[{"type":"text","value":"Row Grouping"}]},{"type":"text","value":" another zero based sequence is used and prefixed with "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"row-group-"}]},{"type":"text","value":". For example Row Groups\nwill have IDs "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"row-group-0"}]},{"type":"text","value":", "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"row-group-1"}]},{"type":"text","value":" and "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"row-group-2"}]},{"type":"text","value":"."}]},{"type":"element","tagName":"h2","properties":{"id":"application-assigned-ids","style":"position:relative;"},"children":[{"type":"text","value":"Application Assigned IDs"},{"type":"element","tagName":"a","properties":{"href":"#application-assigned-ids","ariaLabel":"application assigned ids 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":"When the Application assigns Row IDs, this provides a common Row ID across the grid and the Application. This has advantages such as:"}]},{"type":"element","tagName":"ol","properties":{},"children":[{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"The grid API "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowNode(id)"}]},{"type":"text","value":" can be called with the Application known ID (eg "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"employeeId"}]},{"type":"text","value":") to get the Row Node for a particular piece of data."}]},{"type":"text","value":"\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"text","value":"When updating Row Data (either by updating the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"rowData"}]},{"type":"text","value":" attribute, or using "},{"type":"element","tagName":"a","properties":{"href":"/archive/29.3.1/data-update-transactions/"},"children":[{"type":"text","value":"Update Transactions"}]},{"type":"text","value":"), the grid uses the Row ID to map old vs new data (e.g. it can work out which Rows to add / remove / update rather than doing a blanket replacement of old vs new data). This allows the grid to keep state such as Row Selection."}]},{"type":"text","value":"\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Setting Row IDs is done using the "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowId()"}]},{"type":"text","value":" grid callback:"}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"api-documentation","properties":{"source":"grid-options/properties.json","section":"rowModels","names":"[\"getRowId\"]"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"When the row data contains a unique row identifier, such as a Database Primary Key, "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowId()"}]},{"type":"text","value":" can be implemented as follows: "}]},{"type":"element","tagName":"snippet","properties":{},"children":[{"type":"text","value":"\nconst gridOptions = {\n    // assumes each data item provided by the application has the ID stored in an attribute called id\n    getRowId: params => params.data.id\n}\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The example below has "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"getRowId()"}]},{"type":"text","value":" implemented to return "},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"params.data.id"}]},{"type":"text","value":". The Row ID is displayed inside the first Column."}]},{"type":"element","tagName":"div","properties":{},"children":[{"type":"element","tagName":"grid-example","properties":{"title":"Get Row ID","name":"get-row-id","type":"generated","options":" { \"modules\": [\"clientside\"] }"},"children":[]}]}]},"frontmatter":{"title":"Row IDs","version":null,"enterprise":null,"sideMenu":null,"description":null},"headings":[{"id":"grid-assigned-ids","depth":2,"value":"Grid Assigned IDs"},{"id":"application-assigned-ids","depth":2,"value":"Application Assigned IDs"}]}},"pageContext":{"frameworks":["javascript","react","angular","vue"],"framework":"javascript","srcPath":"/row-ids","pageName":"row-ids"}},
    "staticQueryHashes": ["1766026005","699667431","940729948"]}