score:7

Accepted answer

i am sorry for not adding a comment i don't have the reputation yet. x will note you the number you are asking but don't try to update offset with x cause of the offset calculation defined on core.ts of the module.

export const getoffset = (page: number, limit: number): number => { const offset = (page - 1) * limit; return offset < 0 ? 0 : offset; };

although you can try to get the html you want by parsing the event. a trick is to match a case with the params that the interface provide like next or previous labels

e.target.innertext
e.currenttarget.childnodes[0].innertext

*mind it is a string so care your number comparisons

import react from "react";
import reactdom from "react-dom";
import cssbaseline from "@material-ui/core/cssbaseline";
import { createmuitheme, muithemeprovider } from "@material-ui/core/styles";
import pagination from "material-ui-flat-pagination";

const theme = createmuitheme();

class example extends react.component {
constructor(props) {
    super(props);
    this.state = { offset: 0, limit: 3, total: 132, calc: 1, nlabel: ">>", plabel: "<<" };
}

handleclick(e, offset) {
    let y = e.target.innertext; 
    //let y =e.currenttarget.childnodes[0].innertext;

    if (y === this.state.plabel) y = number(this.state.calc) - 1;
    if (y === this.state.nlabel) y = number(this.state.calc) + 1;
    let x = offset / this.state.limit + 1;
    console.log("x:" + x + " - y:" + y);
    this.setstate({ offset, calc: y });
}

render() {
    return (
        <muithemeprovider theme={theme}>
            <div>{this.state.offset}</div>
            <div>{this.state.calc}</div>
            <cssbaseline />
            <pagination
                limit={this.state.limit}
                offset={this.state.offset}
                total={this.state.total}
                onclick={(e, offset) => this.handleclick(e, offset)}
                nextpagelabel={this.state.nlabel}
                previouspagelabel={this.state.plabel}
            />
        </muithemeprovider>
    );
}
}

reactdom.render(<example />, document.getelementbyid("root"));

Related Query

More Query from same tag