-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
about deleting rows #1401
Comments
Sorry, we only give the rowkeys only, does any case that you can't get the row with rowkey? I think this issues is very minor, I'll open it if there have any concern or critical issue, thanks |
By having the content of the rows needed for deletion we can ensure that the data that is needed to be deleted will be deleted and no more, no less. Deleting is very critical but the use of the row keys is not and somehow it could be a great idea to be able to be independent of them as much as possible. In my case, I am using as a row key a column that doesn't exist in the DB so I could use the Boot Strap table. To solve this problem I had to create a state to contain all the selected rows. But, I had to trace all the transactions to destroy, add or delete elements from this set. I know, it looks minor, but given that the deletion of rows is very important topic then that capability to return the rows (including their content) could be paramount -as in my case- |
ok, I'll try to add row for you, thanks |
Hi @AllenFang , So base on examples, I am trying to get the key property of the data I am trying to delete, then send the request to back-end for deleting it in database.
I also check the issue: #1243, I think it is pretty similar with my purpose, but still don't understand the examples... Please give some advises of it. Thank you so much |
Hi @XidongHuang, like I mention in #1243, You can try to use so in the redux, you can:
handleDeleteRow(row) {
this.props.deleteAction(row);
}
render() {
return (
<BootstrapTable data={ this.props.data }
remote={ true } << important
deleteRow={ true }
selectRow={ { mode: 'radio' } }
options={ { onDeleteRow: this.handleDeleteRow} }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
</BootstrapTable>
);
}
export function deleteAction(row) {
return dispatch => {
// do your ajax call here to delete the row
// then dispatch a Action to reducers if success
}
}
const initialState = {
data: .... // << this is the data for your table
}
export default function(state = initialState, action) {
switch(action.type) {
case: "successful_delete":
// delete the row from current state and return it as new state
}
} Note: in Let me know if you have any questions, thanks :) |
@jcabrerazuniga, your requirement was fixed on now, you can get whole rows on |
@AllenFang Thanks sir, I got the solution. Just found your example and it is very clear in the doc, I didn't think remote is the way to get the deleting data before. And I have other questions here:
//Table.js
...
createCustomModalBody = () => {
return <RegisterForm />
}
onAddRow(row) {
console.log('insert row', row);
}
options = {
...
insertModalBody: this.createCustomModalBody,
onAddRow: this.onAddRow
}
render() {
return (
<BootstrapTable
....
insertRow={true}
remote={true}
options={this.options}>
....
</BootstrapTable>
)
} in my //RegisterForm.js
...
getFieldValue() {
return {test: 'test'}; //so this object should be printed in onAddRow in Table.js
}
render() {
return (
....
)
}
...
export default connect(null, {someMethods})(RegisterForm); //Throw `Custom InsertModalBody should implement getFieldValue...`
export default RegisterForm; --> //It can print {test: 'test'}
... Or your original goal just want us export a pure component, and just pass //Table.js
...
createCustomModalBody = () => {
return <RegisterForm isAccountExists={this.props.isAccountExists}/>
}
export default connect(mapStateToProps, {isAccountExists})(Table);
... //RegisterForm.js
...
checkUserExists(e) {
this.props.isAccountExists(this.state.xxx);
}
...
export default RegisterForm; Please give some ideas about these, update:
...
confirmDelete = (next, dropRowKeys) => {
console.log('delete', dropRowKeys); // will print "delete ${key of row you are trying to delete}"
next();
}
options = {
...
handleConfirmDeleteRow: this.confirmDelete,
...
}
<BootstrapTable
deleteRow
remote={true}
options={this.options}
>
...
</BootstrapTable> reference: del-row-custom-confirm.js
|
Thanks a lot @AllenFang. So, you mean that for the call back: onDeleteRow(rows) { there is another parameter like: onDeleteRow(rows, fullrows) { ? |
Is there any command that after deleting a row or a set of rows will return me the list of all the deleted rows? not just their respective indexes?
The text was updated successfully, but these errors were encountered: