" import MaterialTable from 'material-table'
import { StyledContainer } from './index.styles'
import { getData } from '../../service/service'
const defaultOptions = {
search: false,
searchFieldAlignment: 'right',
searchAutoFocus: true,
searchFieldStyleheader styledisableUnderline: true,
},
headerStyle: {
color: 'black',
backgroundColor: '#E3E6F2',
fontFamily: 'DM Sans',
font-size: '10px',
font-weight: 800,
border: '1px solid #701d9f',
},
rowStyle: {
fontFamily: 'DM Sans',
font-size: '16px',
border: '1px solid #eee',
},
cellStyle: {
border: '1px solid #eee',
alignItems: 'center',
textAlign: 'center',
},
maxHeight: '500px',
}
function Material({ show title, title, columns, baseUrl, options, actions,
localization }) {
return (
<StyledContainer>
<MaterialTable
title={title}
columns={columns}
data={(query) =>
new Promise((resolve) => {
let url = `${baseUrl}?pageNumber= ${query.page}&searchKeyword=
${query.search}&pageSize= ${query.pageSize}&sortBy=${
query.orderBy?.field || 'id'
}&sortDirection=${query.orderDirection || 'desc'}`
getData(url).then((result) => {
resolve({
data: result.data.data,
page: result.data.pageNumber,
totalCount: result.data.totalCount,
publishDate: result.data.publishDate,
})
})
})
}
options={{ ...defaultOptions, ...options }}
actions={actions}
localization={localization}
style={{ fontFamily: 'DM Sans', maxHeight: "800px", overflow:"scroll"}}
/>
</StyledContainer>
)
}
export default Material "
- I don't want the page number to be reset when the page is refreshed. I tried to keep the page in state, unfortunately it did not work. we use this table in the whole project, but unfortunately we could not solve this page problem. i can go to other pages, but when i go back to do any operation, it goes to page 0, not to the page i left.*