Skip to content
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

Custom functions and components for insert and delete. #168

Closed
risonsimon opened this issue Dec 4, 2015 · 2 comments
Closed

Custom functions and components for insert and delete. #168

risonsimon opened this issue Dec 4, 2015 · 2 comments

Comments

@risonsimon
Copy link

Two things.

  1. I see that my state is mutated when I insert or delete the row. I'm using redux for development and I want to fire custom actions when insert or delete is done. How to achieve this?
    For insert, I think I can create a component with onclick showing a modal popup and calling the necessary actions. But how to do it for delete?
  2. How can I customize insert button and form and delete button?
@AllenFang
Copy link
Owner

@risonsimon, thanks your feedback, I'll tell you how to achieve your requirement in these days :) Maybe provide you example codes.

@AllenFang
Copy link
Owner

@risonsimon, plz upgrade to v1.3.0 and try following examples:

export default class DemoTable extends React.Component{

  handleInsertBtnClick(e){
    var fakeRow = {
      id: 10,
      name: "Product one ",
      price: 240
    };
    // insert a fake row
    var result = this.refs.table.handleAddRow(fakeRow);
    if(result){  //some error happen, ex: doesn't assign row key or row key duplicated
      console.log(result);
    }
  }

  handleDropBtnClick(e){
    //Drop row key 2 & 3
    this.refs.table.handleDropRow([2,3]);
  }

  render(){
    return (
      <div>
      <button onClick={this.handleInsertBtnClick.bind(this)}>insert an row</button>
      <button onClick={this.handleDropBtnClick.bind(this)}>Drop Product ID 2 and 3</button>
      <BootstrapTable ref="table" data={products}>
          <TableHeaderColumn dataField="id" isKey={true}>Product ID</TableHeaderColumn>
          <TableHeaderColumn dataField="name">Product Name</TableHeaderColumn>
          <TableHeaderColumn dataField="price">Product Price</TableHeaderColumn>
      </BootstrapTable>
      </div>
    );
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants