Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

211
Views
SPFx Modal open with a regular html button in datatables.net

I´m using this solution in order to open modals in my React SPFx webpart, the problem is I have to open this modal from a Button in a datatable (datatables.net), since the OnClick() don't exist, only onclick() I'm having a problem calling the modal.

Is it possible put it to work?

This is the Modal link sample https://www.c-sharpcorner.com/article/modal-popup-in-spfx/

In the datatables I tried

{
    data: null,
    render: function (data, type, row, meta) {
    return '<input type="button" class="name" id=n-"' + meta.row + '" value="Edit"/>&nbsp<input type="button" class="salary" id=s-"' + meta.row + '" value="Delete"/>';
}

Then

that = this;
$('#example tbody').on('click', '.name', function () {
  var data = table.row($(this).closest('tr')).data();
  that.state.callchildcomponent && <MYModal myprops={that.state} handler={that.handler} />
});

But is expected working like this

public render(): React.ReactElement<ICertificatesListProps> {
    return (
      <div>
       ......


<Button onClick={(e) => this.Buttonclick(e)} variant="contained" color="primary" style={{ float: "right" }}>Add +</Button>
{this.state.callchildcomponent && <MYModal myprops={this.state} handler={this.handler} />}

Handler

 handler() {
    this.setState({
      callchildcomponent: false
    });
  }

Kidnly ask the community for help

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This fragment:

  that.state.callchildcomponent && <MYModal myprops={that.state} handler={that.handler} />

may only work inside of the render function, as far as I understand. So you need to put in the render function, like in your "stock" example with the standard button. I would do that, and inside your button handler, would put something like this instead:

that.setState({
      callchildcomponent: true
    });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!