-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathDatatable.stories.js
151 lines (145 loc) · 3.62 KB
/
Datatable.stories.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React from 'react';
import ReactDatatable from '../src';
import users from '../example/data/data.json';
export default {
title: 'Example/ReactDatatable',
component: ReactDatatable,
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
tags: ['autodocs'],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: 'fullscreen',
},
};
const columns = [
{
key: "name",
text: "Name",
className: "name",
TrOnlyClassName:"aClass",
align: "left",
sortable: true,
},
{
key: "address",
text: "Address",
className: "address",
align: "left",
sortable: true
},
{
key: "postcode",
text: "Postcode",
className: "postcode",
sortable: true
},
{
key: "rating",
text: "Rating",
className: "rating",
align: "left",
sortable: true,
cell: record => {
return <span>{record.rating} {record.type_of_food}</span>
}
},
{
key: "type_of_food",
text: "Type of Food",
className: "type_of_food",
sortable: true,
align: "left"
},
{
key: "action",
text: "Action",
className: "action",
width: 100,
align: "left",
sortable: false,
cell: record => {
return (
<>
<button
className="btn btn-primary btn-sm"
onClick={() => this.editUser(record)}
style={{marginRight: '5px'}}>
<i className="glyphicon glyphicon-edit fa fa-edit"></i>
</button>
<button className="btn btn-danger btn-sm" onClick={() => this.deleteUser(record)}>
<i className="glyphicon glyphicon-trash fa fa-trash"></i>
</button>
</>
);
}
}
];
const config = {
key_column: '_id',
page_size: 10,
length_menu: [ 10, 20, 50 ],
filename: "Users",
no_data_text: 'No data available!',
button: {
excel: true,
print: true,
csv: true,
extra: false,
},
language: {
length_menu: "Show _MENU_ result per page",
filter: "Filter in records...",
info: "Showing _START_ to _END_ of _TOTAL_ records",
pagination: {
first: "First",
previous: <span>◄</span>,
next: <span>►</span>,
last: "Last"
}
},
pagination: "advance", //advance
show_length_menu: true,
show_filter: true,
show_pagination: true,
show_info: true,
};
const extraButtons =[
{
className:"btn btn-primary buttons-pdf",
title:"Export TEst",
children:[
<span>
Button
</span>
],
onClick:(event)=>{
console.log(event);
},
},
{
className:"btn btn-primary buttons-pdf",
title:"Export TEst",
children:[
<span>
Button
</span>
],
onClick:(event)=>{
console.log(event);
},
onDoubleClick:(event)=>{
console.log("doubleClick")
}
},
]
export const Default = {
component: ReactDatatable,
args: {
id: "data-table",
className: "table table-bordered table-striped custom-class",
config,
records: users,
columns,
extraButtons,
},
};