Getting Started
​DataGrid Library is a simple and powerful solution to enable sorting, filtering, and pagination on any page.
On behalf of our team, we would like to thank you for purchasing this library. Your support encourages us to build better plugins and continuously bring value to our products. This documentation file covers all the information needed to install and use this library.

Bootstrap 5 Example

Let's build a page based on Bootstrap 5 with a text filter by item title. Get started with a minimal Bootstrap layout as described in Bootstrap 5 documentation:
index.html
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<title>DataGrid Example</title>
5
​
6
<!-- Required meta tags -->
7
<meta charset="utf-8" />
8
<meta name="viewport"
9
content="width=device-width, initial-scale=1, shrink-to-fit=no" />
10
​
11
<!-- Bootstrap CSS -->
12
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
13
rel="stylesheet"
14
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
15
crossorigin="anonymous" />
16
</head>
17
<body>
18
​
19
​
20
<!-- Bootstrap Script (Optional) -->
21
<script
22
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
23
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
24
crossorigin="anonymous"></script>
25
</body>
26
</html>
Copied!
DataGrid library can be used with any CSS Framework or with your custom HTML & CSS.
Copy-paste the stylesheet <link> into your <head> to load DataGrid CSS:
1
<link href="datagrid.min.css" rel="stylesheet" />
Copied!
Place the <script> near the end of your pages, right before the closing </body> tag:
1
<script src="datagrid.min.js"></script>
Copied!
Add a container element that will hold all items that need to be filtered, sorted, etc. This container should have thedata-gridattribute.
1
<div class="container">
2
<div class="row" data-grid>
3
<!-- content -->
4
</div>
5
</div>
Copied!
Add several items to the container. The items can have any HTML layout, for example like this:
1
<div class="container">
2
<div class="row" data-grid>
3
4
<!-- item #1 -->
5
<div class="col" data-grid-item>
6
<p class="title">Lorem ipsum sed</p>
7
</div>
8
9
<!-- item #2 -->
10
<div class="col" data-grid-item>
11
<p class="title">Est ullamcorper eget</p>
12
</div>
13
14
<!-- item #2 -->
15
<div class="col" data-grid-item>
16
<p class="title">Amet tellus cras</p>
17
</div>
18
19
<!-- more items ... -->
20
21
</div>
22
</div>
Copied!
​
​
Every item should havedata-grid-item attribute.
Let's add text filter control:
1
<div class="row mb-4">
2
<div class="col">
3
<input
4
type="text"
5
class="form-control"
6
placeholder="Filter by title"
7
data-grid-control="text-filter"
8
data-path=".title"
9
/>
10
</div>
11
</div>
Copied!
data-path attribute points to the text that should be filtered. It accepts any valid CSS selector string, for example, class or ID.
Add DataGrid library initialization:
1
<script>
2
datagrid();
3
</script>
Copied!
DataGrid settings can be passed in the following way:
1
<script>
2
datagrid({
3
// Settings ....
4
});
5
</script>
Copied!
The final version:
index.html
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<title>DataGrid Example</title>
5
​
6
<!-- Required meta tags -->
7
<meta charset="utf-8" />
8
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
9
​
10
<!-- Bootstrap CSS -->
11
<link href="//cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
12
rel="stylesheet"
13
integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
14
crossorigin="anonymous" />
15
16
<!-- DataGird CSS -->
17
<link href="datagrid.min.css" rel="stylesheet" />
18
</head>
19
<body>
20
21
<div class="container">
22
23
<div class="row mb-4">
24
<div class="col">
25
26
<!-- text filter by title -->
27
<input
28
type="text"
29
class="form-control mr-2"
30
placeholder="Filter by title"
31
data-grid-control="text-filter"
32
data-path=".title"
33
/>
34
</div>
35
</div>
36
37
<!-- DataGrid container -->
38
<div class="row" data-grid>
39
40
<!-- item #1 -->
41
<div class="col" data-grid-item>
42
<p class="title">Lorem ipsum sed</p>
43
</div>
44
45
<!-- item #2 -->
46
<div class="col" data-grid-item>
47
<p class="title">Est ullamcorper eget</p>
48
</div>
49
50
<!-- item #2 -->
51
<div class="col" data-grid-item>
52
<p class="title">Amet tellus cras</p>
53
</div>
54
55
<!-- more items ... -->
56
57
</div>
58
</div>
59
​
60
​
61
<!-- Bootstrap Script -->
62
<script
63
src="//cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
64
integrity="sha384-ygbV9kiqUc6oa4msXn9868pTtWMgiQaeYH7/t7LECLbyPA2x65Kgf80OJFdroafW"
65
crossorigin="anonymous"></script>
66
67
<!-- DataGird Script -->
68
<script src="datagrid.min.js"></script>
69
70
<!-- DataGird initialization -->
71
<script>
72
datagrid();
73
</script>
74
</body>
75
</html>
Copied!
Last modified 8mo ago
Copy link