{"action":"closed","issue":{"url":"https://api.github.com/repos/adazzle/react-data-grid/issues/315","repository_url":"https://api.github.com/repos/adazzle/react-data-grid","labels_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/315/comments","events_url":"https://api.github.com/repos/adazzle/react-data-grid/issues/315/events","html_url":"https://github.com/adazzle/react-data-grid/issues/315","id":154685814,"number":315,"title":"Improvements to row selection","user":{"login":"malonecj","id":1432798,"avatar_url":"https://avatars.githubusercontent.com/u/1432798?v=3","gravatar_id":"","url":"https://api.github.com/users/malonecj","html_url":"https://github.com/malonecj","followers_url":"https://api.github.com/users/malonecj/followers","following_url":"https://api.github.com/users/malonecj/following{/other_user}","gists_url":"https://api.github.com/users/malonecj/gists{/gist_id}","starred_url":"https://api.github.com/users/malonecj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malonecj/subscriptions","organizations_url":"https://api.github.com/users/malonecj/orgs","repos_url":"https://api.github.com/users/malonecj/repos","events_url":"https://api.github.com/users/malonecj/events{/privacy}","received_events_url":"https://api.github.com/users/malonecj/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-05-13T10:55:09Z","updated_at":"2016-08-04T16:47:18Z","closed_at":"2016-08-04T16:47:18Z","body":"**Motivation:**\r\nCurrently, the number of selected rows is stored in state of ReactDataGrid. It would be preferable to pass selected rows in as props, so users can programatically set the selected rows and manage this themselves.  It is also desirable to be able to choose how rows are selected in more than one way, i.e via a primary key, as is now possible, by index, or based on a property of row data.\r\n\r\n**Related Issues**\r\nhttps://github.com/adazzle/react-data-grid/issues/228\r\nhttps://github.com/adazzle/react-data-grid/issues/232\r\n\r\n**Current Method**:\r\nRow selection currently works as in the [this example](http://adazzle.github.io/react-data-grid/examples.html#/row-select).  Three props are required to enable row selection\r\n```javascript\r\n    enableRowSelect: React.PropTypes.oneOfType([React.PropTypes.bool, React.PropTypes.string]),\r\n    onRowSelect: React.PropTypes.func,\r\n    rowKey: React.PropTypes.string,\r\n```\r\n\r\n**Proposal**\r\nProvide a single rowSelection property that allows user to specify row selection method.\r\n```javascript\r\n\r\nrowSelection: React.PropTypes.shape({\r\n  showCheckbox: React.PropTypes.bool,\r\n  multiSelect: React.PropTypes.bool, // enables shift select, ctrl + click,\r\n  onRowsSelected: React.PropTypes.func,  //returns an array of the selected node/s,\r\n  onRowsDeselected: React.PropTypes.func,  //returns an array of the unselected node/s\r\n  selectBy: React.PropTypes.oneOfType([\r\n    React.PropTypes.shape({\r\n      indexes: React.PropTypes.arrayOf(React.PropTypes.number).isRequired\r\n    }),\r\n    React.PropTypes.shape({\r\n      isSelectedProp: React.PropTypes.string.isRequired // use a property of row data to check if row is \r\n    }),\r\n    React.PropTypes.shape({\r\n      keys: React.PropTypes.shape({\r\n        values: React.PropTypes.array.isRequired,\r\n        keyProp: React.PropTypes.string.isRequired\r\n      }).isRequired\r\n    })\r\n  ])\r\n})\r\n\r\n// eg. select by index \r\nrowSelection = {\r\n  selectBy: {indexes: [0, 4, 6, 7]}\r\n}\r\n\r\n// select by key\r\nrowSelection = {\r\n  selectBy: {\r\n    keys: {\r\n      rowKey: 'id'\r\n      values: ['1', '2', '6', '9']\r\n     }\r\n   },\r\n   onRowSelected: (row) => {\r\n\r\n    }\r\n}\r\n\r\n// select by property\r\nrowSelection = {\r\n  selectBy: {\r\n    isSelectedProperty: 'selected' // use a property of row data to check if row is selected\r\n  }\r\n}\r\n```\r\n\r\n**Backward Compatability**\r\nIt is intended that the current method of selecting rows will continue to work until version 1.0.0 is released. A deprecation warning will be logged if the existing rowSelection properties are used. Finally, all references to rowSelection in the state of ReactDataGrid will be removed in version 1.0.0\r\n\r\n"}}
{"actor":{"display_login":"malonecj"}}