Comments (7)
pagination: {
enabled: true,
limit: 10,
server: {
url: (prev, page, limit) => ${prev}${prev.includes('?') ? '&' : '?'}limit=${limit}&offset=${page * limit}
},
summary: true,
},
This is how I fixed the bug when not performed search initially
from gridjs.
Hey @Naravyb
Grid.js calls your server
configurations one by one and the prev
in your url
function is the URL of the previous step. In other words, you have a base URL here:
const grid = new Grid({
columns: ['Title', 'Director', 'Producer'],
server: {
url: 'https://swapi.dev/api/films/',
then: data => data.results.map(movie =>
[movie.title, movie.director, movie.producer]
)
}
});
which is https://swapi.dev/api/films/
, then you have the search module:
const grid = new Grid({
search: {
server: {
url: (prev, keyword) => `${prev}?q=${keyword}`
}
}
// ...
});
and prev
is your base URL in this case since you don't have any other server components. Then, let's say you have a pagination module:
const grid = new Grid({
pagination: {
limit: 5,
server: {
url: (prev, page, limit) => `${prev}&limit=${limit}&offset=${page * limit}`
}
},
// ...
});
Now, prev
is actually the URL returned from your search module (the search.server.url
function) and you should NOT use ?
to append the pagination querystring to your URL and &
should be used (because search module already appended the ?q=
querystring.
This is the simplified workflow:
https://swapi.dev/api/films
https://swapi.dev/api/films?q=<keyword>
https://swapi.dev/api/films?q=<keyword>&limit=5&offset=10
This is the order of pipeline steps: https://github.com/grid-js/gridjs/blob/master/src/pipeline/processor.ts#L6-L16 and also make sure to read https://gridjs.io/docs/server-side again.
Note: Grid.js sends the final HTTP request once and when all pipeline steps are executed.
from gridjs.
Hmm that's okay, I already implemented it. But I get it again when adding & pagination urls.
Look this
I also tried this on the gridjs.io website for testing. but why does he keep having errors?
thank u
from gridjs.
while I use code like this, but is there anything more efficient?
search: {
server: {
url: (prev, keyword, page) => `${prev}?q=${keyword}&`
}
},
pagination: {
limit: 15,
server: {
url: (prev, page) => `${prev}?page=${page}`
}
},
and this produces the results as expected but what should be like this?
thank you 👍
from gridjs.
Try:
search: {
server: {
url: (prev, keyword, page) => `${prev}?q=${keyword}`
}
},
pagination: {
limit: 15,
server: {
url: (prev, page) => `${prev}&page=${page}`
}
},
from gridjs.
The hacky ${prev}?q=${keyword}&
does work.
The ${keyword} contains {query}?limit=20&offset=1 which will become http://domain.dev?q=query?limit=20&offset=1 (doubled "?")
Maybe its a bug in concatenation?
from gridjs.
So what the exact solution here?
from gridjs.
Related Issues (20)
- Table background opacity HOT 1
- Compatibility issue? HOT 1
- Being able to resize a column below it's minimum width HOT 1
- IDs are not unique - Violation of SIA-R3 HOT 1
- wide table option error HOT 1
- Server-side search no longer calls to search function HOT 2
- Pagination doesn't reset properly when using server-side search, order & pagination and resetPageOnUpdate=true HOT 1
- Callback on text overflow to customize cell content
- Improve German translations HOT 6
- Empty translated fields fallback to default language.
- Add hint about multiple buttons to Docs/Examples/Customizing/Row buttons
- Error Cannot find module '/src/i18n/language' or its corresponding type declarations.
- Maximum call stack size exceeded error when search is enabled and columns use gridjs.html for formating HOT 3
- Sorting with Undefined Values
- Svelte example with select single row
- Fix events documentation
- Selection plugin not working after update HOT 4
- Table broken by hidden columns in a nested header
- Separate display and sort values
- Support for True Grid Layout to Enhance Data Presentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridjs.