Skip to content

button returns line information when clicked #461

@denys-correia

Description

@denys-correia

Good morning, I'm trying to put a button in the column that, when clicked, returns me information from that row.

I'm trying something like:

 handleTagClick = (row) => {
        console.log(row);
    }
    render() {

        const addbutton = (cell, row) => {
            return (
                <Button onClick={this.handleTagClick(row)}>Ola</Button>
            )
        }
  const columns = [{
            dataField: 'id',
            text: 'ID:',
            hidden: true
        },{
            dataField: 'pessoa.nome',
            text: 'Pessoa:',
            sort: true,
            filter: textFilter()
        }, {
            text: 'Ação:',
            formatter: addbutton,
        }];
       <BootstrapTable
                                id="tableLancamento"
                                filter={filterFactory()}
                                noDataIndication="X"
                                striped keyField='id' data={data} columns={columns}
                                hover
                                rowStyle={rowStyle}
                            />

That way, the button appears in the column, but when clicked, does not print the console log.

As if the method was not being called.

So I removed the parameters.
Stay like this.

  handleTagClick = () => {
        console.log("print");
    }
     const addbutton = (cell, row) => {
            return (
                <Button onClick={this.handleTagClick}>Ola</Button>
            )
        }

That way, he printed the console log.

How can I put a button, which returns me line info when clicked?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions