-
Notifications
You must be signed in to change notification settings - Fork 775
Expose 'Add' and 'Delete' button through refs. #356
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
Comments
@invalidred, I thinks its ok, but these button is a little deep in component hierarchy. so how about just give you a click callback hook for you? |
As for the custom events that I had in mind, Add button click for example, I dont want to use the default Add UI that comes up, rather load some other page when it's clicked. |
@invalidred, if you want a customize UI for adding new row. I suggest dont use embedded insertRow, just custom one by yourself, include button and popup modal. |
Hi Allen, How about a compromise. Just like you have a handleConfirmDeleteRow() that has next parameter passed to it, where if you call next() then the row is deleted. Similarly can we have handleConfirmAddRow() that has next parameter, and if we call next() then it shows the add UI. This would be a big help. |
@invalidred, I've already consider this solution at before. Because the insert modal popup by Anyway, I can control the popup modal programmatic, but It's necessary to use jQuery in BTW, that's why I can support Hope I can answer your question, feel free to discuss with me for the other solution 👍 |
Hi @AllenFang I just upgraded to the 3.0.0 dev branch. Main reason: I need a custom add button without a modal popup. This button would simply insert a new empty row. I've seen you crossed out the "Insert button customizable" and "Insert modal customizable" checkboxes. Could you please show us a concrete example how to implement a custom button that just inserts a new empty row? Thanks :) |
Hi @martinpinto, in my opinion, if you want a add button without a modal popup, I'll suggest you add this button in your component render: render() {
return(
<div>
<button>add</button>
<BootstrapTable>
//...
</BootstrapTable>
</div>
);
} Above example it a very simple case, but you you enable the so in this case, if you use the branch of watch out, if you dont want the popup, just dont call the |
Hi @AllenFang thanks so much for the reply! such a quick response, that is awesome! I tried the examples out and unfortunately they don't seem to be working. I still get the modal window. |
Hi @martinpinto I had a similar problem and here is how i solved the issue. Let me know if you want me to explain this code with more details, or how to use it. import ReactDOM from 'react-dom';
import { BootstrapTable as bt, TableHeaderColumn } from 'react-bootstrap-table';
// The class below is a wrapper around react-bootstrap-table library and overrides
// the Add button click event in the toolbar which launches a form.
// We want to override that behaviour by calling props.options.onAdd event handler
class BootstrapTable extends bt {
componentDidMount() {
super.componentDidMount();
const { onAdd } = this.props.options || {};
const dom = ReactDOM.findDOMNode(this);
const addButton = dom.getElementsByClassName('react-bs-table-add-btn')[0];
if (addButton) {
addButton.onclick = function onclick(event) {
event.stopPropagation();
onAdd();
};
}
}
render() {
return super.render({ ...this.props });
}
}
export {
BootstrapTable,
TableHeaderColumn
}; |
Thank you! That did help and the
when calling the createCustomInsertButton as in the example. |
@martinpinto, how about showing your example? Make it as simple as possible so that I can test on my local :) |
Hi, yes of course :) This is the code: https://gist.github.com/martinpinto/5acc1cf47b761eb2be57a30479f92996 |
@martinpinto left you a comment in your gist. The code sample I provided was to override the onAdd() method triggered by the default addButton. I am not sure about replacing the add Button with your own custom button. However the suggestion on your gist may help you out regardless. |
Hi Allen,
Is it possible to access 'Add' and 'Delete' buttons through refs?
This would be really useful to add custom events and interactions with the button.
The text was updated successfully, but these errors were encountered: