Topic: How to use onChange in MDBTableEditable?

willbelucky free asked 4 years ago


Expected behavior

When a user changes data in a MDBTableEditable, call a function assigned onChange.

Actual behavior

When the data is changed, the function is not called.

Resources (screenshots, code snippets etc.)

import React, { Component } from 'react';
import { MDBBtn, MDBCard, MDBCardHeader, MDBCardBody, MDBTableEditable } from "mdbreact";

class CurveBuildPage extends Component {
  state = {
    columns: ["Tenor", "Interest Rate"],

data: [
  [0.25, 0.0155],
  [0.5, 0.02],
  [0.75, 0.025],
  [1, 0.03]
]

  };

  updateState = (data) => {
    console.log(data);
    this.setState({ data })
  };

  logState = () => {
    console.log(this.state)
  };

  render() {
    return (
      <MDBCard>
        <MDBCardHeader tag="h3" className="text-center font-weight-bold text-uppercase py-4">
          Market Rate
        </MDBCardHeader>
        <MDBCardBody>
          <MDBTableEditable
            striped
            bordered
            columns={this.state.columns}
            data={this.state.data}
            onChange={this.updateState}
          />
          <MDBBtn
            onClick={this.logState}
          >
            Log
          </MDBBtn>
        </MDBCardBody>
      </MDBCard>
    );
  }
}

export default CurveBuildPage;

Konrad Stępień staff answered 4 years ago


Hi @willbelucky,

Thank you for the founded bug!

We will try to fix this in the next release.

Best regards.



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.20.0
  • Device: MacBookPro
  • Browser: Chrome
  • OS: macOS Sierra 10.12.6
  • Provided sample code: No
  • Provided link: No