Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cms
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro-dev_2
cms
Commits
6108d3e1
Commit
6108d3e1
authored
Apr 24, 2021
by
PDuarte
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Datatable pagination ok
parent
3a95c01c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
23 deletions
+25
-23
TableServerSide.js
src/views/settings/projects/TableServerSide.js
+21
-20
index.js
src/views/settings/store/actions/index.js
+4
-3
No files found.
src/views/settings/projects/TableServerSide.js
View file @
6108d3e1
...
@@ -31,22 +31,22 @@ const DataTableServerSide = () => {
...
@@ -31,22 +31,22 @@ const DataTableServerSide = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
dispatch
(
dispatch
(
getData_projects
({
getData_projects
({
page
:
current
Page
,
start
:
(
currentPage
-
1
)
*
rowsPer
Page
,
perPage
:
rowsPerPage
,
length
:
rowsPerPage
,
q
:
searchValue
q
:
searchValue
})
})
)
)
},
[
dispatch
])
},
[
dispatch
])
// ** Function to handle filter
// ** Function to handle filter
const
handleFilter
=
e
=>
{
const
handleFilter
=
valu
e
=>
{
setSearchValue
(
e
.
target
.
value
)
setSearchValue
(
value
)
dispatch
(
dispatch
(
getData_projects
({
getData_projects
({
page
:
current
Page
,
start
:
(
currentPage
-
1
)
*
rowsPer
Page
,
perPage
:
rowsPerPage
,
length
:
rowsPerPage
,
q
:
e
.
target
.
value
q
:
value
})
})
)
)
}
}
...
@@ -56,8 +56,9 @@ const DataTableServerSide = () => {
...
@@ -56,8 +56,9 @@ const DataTableServerSide = () => {
const
handlePagination
=
page
=>
{
const
handlePagination
=
page
=>
{
dispatch
(
dispatch
(
getData_projects
({
getData_projects
({
start
:
(
page
.
selected
)
*
rowsPerPage
,
page
:
page
.
selected
+
1
,
page
:
page
.
selected
+
1
,
perPage
:
rowsPerPage
,
length
:
rowsPerPage
,
q
:
searchValue
q
:
searchValue
})
})
)
)
...
@@ -68,8 +69,8 @@ const DataTableServerSide = () => {
...
@@ -68,8 +69,8 @@ const DataTableServerSide = () => {
const
handlePerPage
=
e
=>
{
const
handlePerPage
=
e
=>
{
dispatch
(
dispatch
(
getData_projects
({
getData_projects
({
page
:
currentPage
,
start
:
0
,
perPage
:
parseInt
(
e
.
target
.
value
),
length
:
parseInt
(
e
.
target
.
value
),
q
:
searchValue
q
:
searchValue
})
})
)
)
...
@@ -78,8 +79,7 @@ const DataTableServerSide = () => {
...
@@ -78,8 +79,7 @@ const DataTableServerSide = () => {
// ** Custom Pagination
// ** Custom Pagination
const
CustomPagination
=
()
=>
{
const
CustomPagination
=
()
=>
{
const
count
=
Number
((
store
.
total
/
rowsPerPage
).
toFixed
(
0
))
const
count
=
Number
((
store
.
totalProjects
/
rowsPerPage
).
toFixed
(
0
))
return
(
return
(
<
ReactPaginate
<
ReactPaginate
previousLabel
=
{
''
}
previousLabel
=
{
''
}
...
@@ -119,14 +119,15 @@ const DataTableServerSide = () => {
...
@@ -119,14 +119,15 @@ const DataTableServerSide = () => {
return
filters
[
k
].
length
>
0
return
filters
[
k
].
length
>
0
})
})
console
.
log
(
store
)
console
.
log
(
store
)
return
store
.
allDataProjects
.
slice
(
0
,
rowsPerPage
)
console
.
log
(
store
.
allDataProjects
)
// if (store.data.length > 0) {
// return store.data
if
(
store
.
allDataProjects
.
length
>
0
)
{
// } else if (store.data.length === 0 && isFiltered) {
return
store
.
allDataProjects
// return []
}
else
if
(
store
.
allDataProjects
.
length
===
0
&&
isFiltered
)
{
// } else {
return
[]
// return store.allData.slice(0, rowsPerPage)
}
else
{
// }
return
store
.
allDataProjects
.
slice
(
0
,
rowsPerPage
)
}
}
}
return
(
return
(
...
...
src/views/settings/store/actions/index.js
View file @
6108d3e1
...
@@ -40,14 +40,15 @@ export const setErrorMsg = params => {
...
@@ -40,14 +40,15 @@ export const setErrorMsg = params => {
// ** Get table Data ///api/datatables/data
// ** Get table Data ///api/datatables/data
export
const
getData_projects
=
params
=>
{
export
const
getData_projects
=
params
=>
{
console
.
log
(
params
)
return
async
dispatch
=>
{
return
async
dispatch
=>
{
await
axios
.
get
(
`
${
process
.
env
.
REACT_APP_API
}
/api/projects`
,
params
await
axios
.
get
(
`
${
process
.
env
.
REACT_APP_API
}
/api/projects`
,
{
params
}
).
then
(
response
=>
{
).
then
(
response
=>
{
dispatch
({
dispatch
({
type
:
'GET_DATA_PROJECTS'
,
type
:
'GET_DATA_PROJECTS'
,
allData
:
response
.
data
.
allD
ata
,
allData
:
response
.
data
.
d
ata
,
// dataProjects: response.data.invoices,
// dataProjects: response.data.invoices,
totalPages
:
response
.
data
.
t
otal
,
totalPages
:
response
.
data
.
recordsT
otal
,
params
:
response
.
data
.
params
params
:
response
.
data
.
params
})
})
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment