Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

342
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda