Skip to content

Commit

Permalink
feat: pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
afshinm committed May 24, 2020
1 parent d1481b2 commit 703113d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
76 changes: 76 additions & 0 deletions docs/examples/pagination.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
id: pagination
title: Pagination
---

import { Grid } from "gridjs";
import CodeBlock from "@theme/CodeBlock"
import { useEffect, useRef } from "react";

Pagination can be enabled by setting `pagination: true`:

<CodeBlock children={
`
const grid = new Grid({
columns: ['Name', 'Email', 'Phone Number'],
pagination: true,
data: [
['John', '[email protected]', '(353) 01 222 3333'],
['Mark', '[email protected]', '(01) 22 888 4444']
]
});
`
}
transformCode={(code) =>
`
function () {
${code}

const wrapperRef = useRef(null);

useEffect(() => {
grid.render(wrapperRef.current);
});

return (
<div ref={wrapperRef} />
);
}
`
} live={true} scope={{ Grid, CodeBlock, useEffect, useRef }} />

You can also change the default settings of the pagination plugin:


<CodeBlock children={
`
const grid = new Grid({
columns: ['Name', 'Email', 'Phone Number'],
pagination: {
limit: 1
},
data: [
['John', '[email protected]', '(353) 01 222 3333'],
['Mark', '[email protected]', '(01) 22 888 4444']
]
});
`
}
transformCode={(code) =>
`
function () {
${code}

const wrapperRef = useRef(null);

useEffect(() => {
grid.render(wrapperRef.current);
});

return (
<div ref={wrapperRef} />
);
}
`
} live={true} scope={{ Grid, CodeBlock, useEffect, useRef }} />

1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
Features: ['mdx'],
Examples: [
'examples/hello-world',
'examples/pagination',
'examples/from'
]
},
Expand Down

0 comments on commit 703113d

Please sign in to comment.