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

332
Views
Search is not working in mui-datatable, reactjs when serverSide is true?

Hey I have implemented mui-datatable in my project. Everything is working good but the search bar is not working when I am enabling serverSide: true in options.

const options = {
    filter: true,
    count: state.count,
    rowsPerPage: state.rowsPerPage,
    serverSide: true,
}

If any clarification regarding this problem you want to know please feel free to ask.

Please Help me.

Regards

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

0

Here I provide some code so that it will be conceptually clear.

Here I declare some states so that we can use these for paging or data loading

const [data, setData] = useState(carStocks);
const [page, setPage] = useState(0);
const [total, setTotal] = useState(0);

Define your method that will call api and set data using setData

function changePage(newTableState) {
    let state = {
        ...tableState, ...newTableState,
        pageNo: newTableState.page + 1,
        pageSize: newTableState.rowsPerPage,
        searchText: newTableState.searchText
    };
    setTableState(state);
    // CALL API with state parameter
    // setData(data);
    // setPage(page);
    // setTotal(total);
}

Here you declare your columns

const columns = [
   {
        name: 'name',
        label: 'Name',
        options: {
            filter: false,
            sort: false,
            viewColumns: true
        }
    },
    {
        name: 'title',
        label: 'TITLE',
        options: {
            filter: false,
            sort: false,
            viewColumns: true
        }
    },
];

Here you declare your options. In options you must use serverSide: true and if you use serverSide: true then you must bind count, page, rowsPerPage with the value based on data size found from api.

const options = {
        serverSide: true,
        count: total,
        page: page,
        rowsPerPage: tableState.pageSize,
        selectableRows: 'multiple',
        searchText: tableState.searchText,
        searchPlaceholder: 'Type Car Title to Search',
        textLabels: {
            body: {
                noMatch: loading ?
                    <CircularProgress color='secondary' size={40} /> :
                    'SORRY_THERE_IS_NO_MATCHING_DATA_TO_DISPLAY'
            }
        },
        onTableChange: (action, newTableState) => {
            switch (action) {
                case 'changePage':
                case 'changeRowsPerPage':
                    changePage(newTableState);
                    break;
                case 'search':
                    changePage(newTableState);
                    break;
                case 'filterChange':
                    handleFilterSubmit(newTableState.filterList);
                    break;
            }
        }
    };

Finally you can use data, columns and options

<MUIDataTable data={data} columns={columns} options={options} />

More Details

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!