{"action":"created","issue":{"url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/1501","repository_url":"https://api.github.com/repos/AllenFang/react-bootstrap-table","labels_url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/1501/labels{/name}","comments_url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/1501/comments","events_url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/1501/events","html_url":"https://github.com/AllenFang/react-bootstrap-table/issues/1501","id":244681294,"number":1501,"title":"TypeError keep throwing if renew data after delete all rows in table","user":{"login":"XidongHuang","id":13139446,"avatar_url":"https://avatars3.githubusercontent.com/u/13139446?v=4","gravatar_id":"","url":"https://api.github.com/users/XidongHuang","html_url":"https://github.com/XidongHuang","followers_url":"https://api.github.com/users/XidongHuang/followers","following_url":"https://api.github.com/users/XidongHuang/following{/other_user}","gists_url":"https://api.github.com/users/XidongHuang/gists{/gist_id}","starred_url":"https://api.github.com/users/XidongHuang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XidongHuang/subscriptions","organizations_url":"https://api.github.com/users/XidongHuang/orgs","repos_url":"https://api.github.com/users/XidongHuang/repos","events_url":"https://api.github.com/users/XidongHuang/events{/privacy}","received_events_url":"https://api.github.com/users/XidongHuang/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-07-21T14:13:38Z","updated_at":"2017-07-23T02:29:24Z","closed_at":"2017-07-23T02:29:24Z","body":"Hi, I have a problem here: \r\nThe table will throw `Uncaught (in promise) TypeError: Cannot read property 'coreId' of undefined` if I renew the `data` source after delete all rows (not matter delete one by one or delete all of them once), but it works fine after I re-fresh page even the table is empty. The Error screen shot:\r\n\r\n![1](https://user-images.githubusercontent.com/13139446/28465761-f5247838-6df7-11e7-8b2a-aa7bd229875d.png)\r\n\r\n![2](https://user-images.githubusercontent.com/13139446/28465763-f6d3e60a-6df7-11e7-8cb9-6963da87a903.jpg)\r\n\r\nAlso, the table is working well for adding (renew `data` source), multi-delete rows (just not delete all).\r\nAnd the way I am working on it is:\r\n```javascript\r\n...\r\nremoteDelete = (row) => {\r\n          \r\n        let settleFlag = 1;\r\n        let settleInfo = {coreId: row};\r\n        this.props.registerDevice(settleInfo, settleFlag).then(\r\n            (res) => {\r\n                // --> renew data source from database after deleted rows\r\n                this.setState({dataArr: res.data.devices, unsettledDevices: res.data.unsettledDevices});\r\n            },\r\n            (err) => {\r\n                console.error(err);\r\n            }\r\n        );\r\n        console.log('delete', settleInfo);\r\n    }\r\n\r\nonAddRow = (row) => {\r\n        let settleFlag = 0;\r\n       \r\n        this.props.registerDevice(row, settleFlag).then(\r\n            (res) => {\r\n                // --> renew data source from database after adding row\r\n                this.setState({dataArr: res.data.devices, unsettledDevices: res.data.unsettledDevices});\r\n            },\r\n            (err) => {\r\n                  console.error(err);\r\n            }\r\n        );\r\n    }\r\n\r\noptions = {\r\n        // paginationPosition:\"top\",\r\n        paginationShowsTotal: this.renderPaginationShowsTotal,\r\n        sizePerPageList: ['10',  '30', '50', '60'],\r\n        sizePerPage: 10,\r\n        sizePerPageDropDown: this.renderSizePerPageDropDown,\r\n        // exportCSVBtn: this.createCustomExportCSVButton,\r\n        defaultSortName: 'coreId',\r\n        defaultSortOrder: 'asc',\r\n        \r\n        handleConfirmDeleteRow: this.confirmDelete,\r\n        onDeleteRow: this.remoteDelete,\r\n\r\n        insertModalHeader: this.modalHeader,\r\n        insertModalBody: this.modalBody,\r\n\r\n        insertText: 'register',\r\n        deleteText: 'unregister',\r\n        \r\n        onAddRow: this.onAddRow,   \r\n    }\r\n\r\n...\r\nrender() {\r\n        const {dataArr, errors, delModalOpen, delNext, delDeviceId} = this.state;\r\n        let data = _.isEmpty(dataArr)? [] : dataArr;\r\n        console.log('device render', data);  //--> The data is correct when the error comes\r\n        const confirmMegs = `Do you want to unregister device:`;\r\n        return (\r\n            <div>\r\n                <BootstrapTable data={data} striped hover search \r\n                    condensed pagination insertRow deleteRow remote={this.remote}  options={this.options} selectRow={this.selectRowProp}>\r\n\r\n                    <TableHeaderColumn isKey tdStyle={{whiteSpace: 'normal', 'wordWrap': 'break-word'}} \r\n                        thStyle={{whiteSpace: 'normal'}} dataFormat={this.coreIdLink} dataField=\"coreId\" dataSort>Core ID</TableHeaderColumn>\r\n                    ...\r\n                </BootstrapTable>\r\n            </div>\r\n}\r\n```\r\nI check the data source when it renew (adding or deleting), they look same, so are there any errors in setting or usage of the table?\r\nPlease give me some hints.\r\nThank you.\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/comments/317224098","html_url":"https://github.com/AllenFang/react-bootstrap-table/issues/1501#issuecomment-317224098","issue_url":"https://api.github.com/repos/AllenFang/react-bootstrap-table/issues/1501","id":317224098,"user":{"login":"AllenFang","id":5351390,"avatar_url":"https://avatars2.githubusercontent.com/u/5351390?v=4","gravatar_id":"","url":"https://api.github.com/users/AllenFang","html_url":"https://github.com/AllenFang","followers_url":"https://api.github.com/users/AllenFang/followers","following_url":"https://api.github.com/users/AllenFang/following{/other_user}","gists_url":"https://api.github.com/users/AllenFang/gists{/gist_id}","starred_url":"https://api.github.com/users/AllenFang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AllenFang/subscriptions","organizations_url":"https://api.github.com/users/AllenFang/orgs","repos_url":"https://api.github.com/users/AllenFang/repos","events_url":"https://api.github.com/users/AllenFang/events{/privacy}","received_events_url":"https://api.github.com/users/AllenFang/received_events","type":"User","site_admin":false},"created_at":"2017-07-23T02:29:23Z","updated_at":"2017-07-23T02:29:23Z","body":"@XidongHuang sorry for lately reply, few questions\r\n\r\n1. I wanna check your `this.remote` function\r\n2. \r\n> if I renew the data source after delete all rows (not matter delete one by one or delete all of them once),\r\nHow you renew the data? By `onAddRow` function?  if yes, please try to return in the end;\r\n\r\n```js\r\nonAddRow = (row) => {\r\n        let settleFlag = 0;\r\n       \r\n        this.props.registerDevice(row, settleFlag).then(\r\n            (res) => {\r\n                // --> renew data source from database after adding row\r\n                this.setState({dataArr: res.data.devices, unsettledDevices: res.data.unsettledDevices});\r\n            },\r\n            (err) => {\r\n                  console.error(err);\r\n            }\r\n        );\r\n        return 'some error';   // < return error message sync if there're some error\r\n        return;  // << return nothing means no error, just execute directly, you should use this one\r\n        return false;  // << means your error message will be handled as async, please check following\r\n}\r\n```\r\nBTW, in the `onAddRow` your operation is async, so you can have some improvement on handling the error message async, you can check [this](https://github.com/AllenFang/react-bootstrap-table/commit/c7b08e421bae5bccf43caeeca8fcd96011b13681)\r\n\r\nIt's a patch on this month, #1391. Please use it if it's helpful to you. Please let me know if there's any unclear for my description, thanks\r\n\r\nAlso let me know if the bug still remain.\r\n"}}
{"actor":{"display_login":"AllenFang"}}