Skip to content

Dynamic data and pagination/sort/search #1453

Closed Answered by AdrianVollmer
AdrianVollmer asked this question in Q&A
Discussion options

You must be logged in to vote

I realized I can use the custom HTTP client and pass options via the url parameter:

	const grid = new gridjs.Grid({
		columns: columns,
		server: {
			data: (opts) => queryDb(opts),
		},
		pagination: {
			limit: 20,
			server: {
				data: (opts) => queryDb(opts),
				url: (prev, page, limit) => {
					const result = prev || {};
					result.page = page;
					result.limit = limit;
					return result;
				},
			},
		},
		search: {
			server: {
				url: (prev, keyword) => {
					const result = prev || {};
					result.keyword = keyword;
					return result;
				},
			},
		},
		sort: {
			multiColumn: true,
			server: {
				url: (prev, columns) => {
					if (!columns.length) return prev;

					c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by AdrianVollmer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant