Untitled

 avatar
user_3426652142
plain_text
3 years ago
1.7 kB
1
Indexable
Never
// material ui used here


handleprint = (e) => {

        var divToPrint = document.getElementById("table");
        var newWin = window.open("");
        newWin.document.write(divToPrint.outerHTML);
        newWin.print();
        newWin.close();
        
    }


 <Table id='table'>
                        <TableHead>
                            <TableRow id='tablehead'>
                                <TableCell>Doctor Name</TableCell>
                                <TableCell>Service Name</TableCell>
                                <TableCell>Count</TableCell>
                                <TableCell>Amount</TableCell>
                            </TableRow>
                        </TableHead>


                        {filtereddata.slice(this.state.page * this.state.rowsPerPage,
                            this.state.page * this.state.rowsPerPage + this.state.rowsPerPage)
                            .map((val, key) => {
                                return (

                                    <TableBody>
                                        <TableRow key={key}>
                                            <TableCell>{val.doctor_name}</TableCell>
                                            <TableCell>{val.service_name}</TableCell>
                                            <TableCell>{val.count}</TableCell>
                                            <TableCell>{val.amount}</TableCell>
                                        </TableRow>
                                    </TableBody>
                                )
                            })}
                    </Table>

                        <Button variant='contained' onClick={this.handleprint}>Print</Button>