Giter Site home page Giter Site logo

Comments (3)

gregnb avatar gregnb commented on July 19, 2024

It looks like there's a bug. I will look into this today

from mui-datatables.

gregnb avatar gregnb commented on July 19, 2024

This issue should be resolved. Upgrade to version 2.0.0-beta-3

from mui-datatables.

skalma avatar skalma commented on July 19, 2024

Hi Greg,
First of all, thx for this library, saves me tons of work. I'm a newbee to javascript so there could be a very simple explanation to this,, but i am experiencing this very same issue on version 2.0.0-beta-37. My code:
''''js
import * as React from 'react';
import MUIDataTable from "mui-datatables";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles';

export class ClientList extends React.Component {

state = {
    page: 0,
    count: 100,
    rowsPerPage: 10,
    data: []
};


getMuiTheme = () => createMuiTheme({
    overrides: {
        MuiMenuItem: {
            root: {
                fontSize: '1.25rem'
            }
        }
        , MuiChip: {
            label: {
                fontSize: '1.25rem'
            }
        }
        , MuiInputLabel: {
            root: {
                fontSize: '1.5rem'
            }
        }
        , MuiTooltip: {
            tooltip: {
                fontSize: '1.25rem'
            }
        }
        , MuiInputBase: {
            input: {
                fontSize: '1.25rem'
            }
        }
        , MuiSelect: {
            selectMenu: {
                fontSize: '1.25rem'
            }
        }
        , MuiTypography: {
            h6: {
                fontSize: '2rem'
            }
            , caption: {
                fontSize: '1.25rem'
            }
        }
        , MUIDataTableHeadCell: {
            root: {
                fontSize: '1.25rem'
                , fontWeight: 'bold'
            }
        }
        , MUIDataTableBodyCell: {
            root: {
                fontSize: '1.25rem'
                //,backgroundColor: "#FF0000"
            }
        }
    }
})

componentDidMount() {
    this.getClientListWrapper(0,10);
}

onChangeRowsPerPage = rowsPerPage => {
    this.setState({ rowsPerPage });
};

// get data
//getData = () => {
//    this.getClientList().then(data => {
//        this.setState({ data });
//    });
//}

//get list of clients
getClientList = () => {
    return new Promise((resolve, reject) => {
        fetch('api/Client/Index')
            .then(function (response) { return resolve(response.json()); })
            //.then(function (myJson) { console.log(JSON.stringify(myJson)); })
            ;
    });
}

//route to client overview page
showClientOverview = (id) => {
    this.props.history.push("/client/edit/" + id);
};

getClientListWrapper = (page, rowsPerPage) => {
    this.getClientList().then(data => {
        this.setState({
            page: page,
            rowsPerPage: rowsPerPage,
            data
        });
    });
};

render() {
    const columns = [{ name: "Id", options: { display: false } }, "Clientnummer", "Naam", "Airline"];
    const { data, page } = this.state;
    const data1 = data.map(item => { return [item.clientId, item.clientNumber, item.fullName, item.companyName] });
    const options = {
        filter: true
        ,filterType: 'dropdown'
        ,responsive: 'stacked'
        ,serverSide: false
        ,count: data1.length
        ,page: page
        ,rowsPerPage: this.state.rowsPerPage
        ,rowsPerPageOptions: [10, 15, 50, 100]
        ,onChangeRowsPerpage: this.onChangeRowsPerPage
        ,onRowClick: (rowData, rowMeta) => {
            this.showClientOverview(rowData[0])
        }                
        ,onTableChange: (action, tableState) => {

            //console.log(action, tableState);
            // a developer could react to change on an action basis or
            // examine the state as a whole and do whatever they want

            switch (action) {
                case 'changePage':
                    this.getClientListWrapper(tableState.page, tableState.rowsPerPage);
                    break;
            }
            
        }
        //TODO: load labels from label table 
        ,textLabels: {
            body: {
                noMatch: "Clienten laden...",
                toolTip: "Sorteren",
            }
            , pagination: {
                next: "Volgende Pagina",
                previous: "Vorige Pagina",
                rowsPerPage: "Aantal objecten per pagina:",
                displayRows: "van",
            }
            , toolbar: {
                search: "Zoek",
                downloadCsv: "Download CSV",
                print: "Print",
                viewColumns: "Filter Kolommen",
                filterTable: "Filter Tabel",
            }
            , filter: {
                all: "Alles",
                title: "Filters",
                reset: "Verwijder Filters",
            }
            , viewColumns: {
                title: "Toon Kolommen",
                titleAria: "Toon/Verberg Kolommen",
            }
            , selectedRows: {
                text: "geselecteerde rij(en)",
                delete: "Verwijder",
                deleteAria: "Verwijder Geselecteerde Rijen",
            }
        }
    };

    return (
        <MuiThemeProvider theme={this.getMuiTheme()}>
            <MUIDataTable title={"Team Vervoort - Clienten"} data={data1} columns={columns} options={options} />
        </MuiThemeProvider>   
    );

}

}
''''
I have 21 clients in my database. When navigating to last page (2) there is one last client on that page. If i change rowsPerPage to 15 then, the page goes blank. Refreshing it defaults to first page, rowsPerPage = 10. However: changing rowsPerPage to 50 or 100 works perfectly. Any ideas?

from mui-datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.