-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
97 lines (90 loc) · 3.15 KB
/
index.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
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
PanResponder,
SafeAreaView
} from 'react-native';
import EditableTable from './editabletable.js';
class editabletable extends Component{
componentWillMount() {
this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: (e) => {console.log('onStartShouldSetPanResponder'); return true;},
onMoveShouldSetPanResponder: (e) => {console.log('onMoveShouldSetPanResponder'); return true;},
onPanResponderGrant: (e) => console.log('onPanResponderGrant'),
onPanResponderMove: (e) => console.log('onPanResponderMove'),
onPanResponderRelease: (e) => console.log('onPanResponderRelease'),
onPanResponderTerminate: (e) => console.log('onPanResponderTerminate')
});
}
render(){
return (
<SafeAreaView style={styles.container}>
<Text style={styles.welcome}>
Welcome to react-native-editable-table example!
</Text>
<EditableTable
columns={[
{value: 'Col 1', input: 'c1', width: 20, sortable: true, defaultSort: 'ASC', reorder: true},
{value: 'Col 2', input: 'c2', width: 20, sortable: false, editable: true, reorder: true},
{value: 'Col 3', input: 'c3', width: 30, sortable: false, editable: true},
{value: 'Col 4', input: 'c4', width: 30, sortable: true}
]}
values={[
[10, 'test', 23, ':)'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[30, {value: 'Extra Editable Rows', span: 2}, 'Dang'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[20, {value: 'Edit Me', editable: true}, {value: 45}, 'haha'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)'],
[10, 'test', 23, ':)']
]}
emptyRows={2}
onCellChange={(value, column, row, unique_id) => {
console.log(`Cell Change on Column: ${column} Row: ${row}
and unique_id: ${unique_id}`);
}}
onColumnChange={(value, oldVal, newVal) => {
console.log(`Column Change. Old Value: ${oldVal} New Value: ${newVal}`);
}}
customStyles={{
}}
style={styles.table}
/>
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#F5FCFF'
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5
},
table: {
flex: 1,
marginBottom: 30
}
});
AppRegistry.registerComponent('editabletable', () => editabletable);