admin管理员组文章数量:1391977
Hy! I'm new in react native development and using expo-cli. I add a react-native-paper datatable in my app its working fine but I have many fields I want to scroll a screen in the horizontal direction but I can't understand who to do it. Kindly suggest to me what I can do for this problem.
import React from 'react';
import { StyleSheet, Text, View, ScrollView, TextInput, Button, } from 'react-native';
import { Card } from "react-native-shadow-cards";
import {DataTable} from "react-native-paper"
const AllUsers = () =>{
return(
<View>
<View style={styles.headSection}>
<Text style={styles.titleHeading}>All Users</Text>
</View>
<ScrollView horizontal>
<DataTable style={styles.table} >
<DataTable.Header>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading}>Id</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Username</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
</DataTable.Header>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Pagination
page={1}
numberOfPages={3}
onPageChange={(page) => { console.log(page); }}
label="1-2 of 6"
/>
</DataTable>
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
table:{
},
headSection:{
borderBottomWidth:2,
borderColor:'black',
paddingBottom:15,
},
titleHeading:{
marginTop:50,
fontWeight:'bold',
marginHorizontal:167,
},
tableHeading:{
fontWeight:'bold',
color:'black',
},
header:{
paddingLeft:0,
},
});
export default AllUsers;
Here's above code is having three fields but I want to add more fields. but want to scroll in the horizontal direction.
Hy! I'm new in react native development and using expo-cli. I add a react-native-paper datatable in my app its working fine but I have many fields I want to scroll a screen in the horizontal direction but I can't understand who to do it. Kindly suggest to me what I can do for this problem.
import React from 'react';
import { StyleSheet, Text, View, ScrollView, TextInput, Button, } from 'react-native';
import { Card } from "react-native-shadow-cards";
import {DataTable} from "react-native-paper"
const AllUsers = () =>{
return(
<View>
<View style={styles.headSection}>
<Text style={styles.titleHeading}>All Users</Text>
</View>
<ScrollView horizontal>
<DataTable style={styles.table} >
<DataTable.Header>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading}>Id</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Username</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >First Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Last Name</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
</DataTable.Header>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
<DataTable.Cell>Adil</DataTable.Cell>
<DataTable.Cell>IJaz</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Pagination
page={1}
numberOfPages={3}
onPageChange={(page) => { console.log(page); }}
label="1-2 of 6"
/>
</DataTable>
</ScrollView>
</View>
)
}
const styles = StyleSheet.create({
table:{
},
headSection:{
borderBottomWidth:2,
borderColor:'black',
paddingBottom:15,
},
titleHeading:{
marginTop:50,
fontWeight:'bold',
marginHorizontal:167,
},
tableHeading:{
fontWeight:'bold',
color:'black',
},
header:{
paddingLeft:0,
},
});
export default AllUsers;
Here's above code is having three fields but I want to add more fields. but want to scroll in the horizontal direction.
Share Improve this question edited Apr 7, 2021 at 16:50 Adil Ijaz asked Apr 7, 2021 at 15:51 Adil IjazAdil Ijaz 3621 gold badge5 silver badges27 bronze badges1 Answer
Reset to default 5To enable horizontal scrolling, you can put the content you want to scroll in a ScrollView ponent with horizontal as a prop like this:
<ScrollView horizontal>
<DataTable style={styles.table} >
<DataTable.Header>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading}>Id</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Username</Text></DataTable.Title>
<DataTable.Title style={styles.header} > <Text style={styles.tableHeading} >Email</Text></DataTable.Title>
</DataTable.Header>
<DataTable.Row>
<DataTable.Cell>1.</DataTable.Cell>
<DataTable.Cell>adiljaz02</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Row>
<DataTable.Cell>2.</DataTable.Cell>
<DataTable.Cell>adil09</DataTable.Cell>
<DataTable.Cell>[email protected]</DataTable.Cell>
</DataTable.Row>
<DataTable.Pagination
page={1}
numberOfPages={3}
onPageChange={(page) => { console.log(page); }}
label="1-2 of 6"
/>
</DataTable>
</ScrollView>
本文标签: javascripthow to add scrollbar in horizontal in datatable react native paperStack Overflow
版权声明:本文标题:javascript - how to add scrollbar in horizontal in datatable react native paper? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744634501a2616741.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论