[英]How to get Data from Realm for my ListView
I have a problem, in my first screen LaunchScreen , i have a button for adding some data in my Realm : 我有一个问题,在我的第一个屏幕LaunchScreen中 ,我有一个用于在Realm中添加一些数据的按钮:
addBdd(realm){
realm.write(() => {
realm.create('Bills', {
type: "Fournitures",
creditor: "Entreprise A",
month: "Avril",
year: "2017",
price: "40",
})
});
alert("Count : " + realm.objects('Bills').length);
}
All is working this far. 到目前为止,所有人都在工作。 But after that, i have two views, a LoginScreen , and the View where data must be applied to my list view : ListBillScreen 但是在那之后,我有两个视图,一个LoginScreen和一个必须将数据应用于我的列表视图的视图: ListBillScreen
<ListView
enableEmptySections={true}
style={styles.listView}
dataSource={this.state.dataSource}
renderRow={(data) => <Row {...data} navigator={this.props.navigator} />}
renderSeparator={(sectionId, rowId) => <View key={rowId} style={styles.separator} />}
/>
Which calls a class named Row : 哪个调用名为Row的类:
function goBillscreen() {
props.navigator.push({ screen: 'BillScreen', props: {
billType : props.type,
billCreditor : props.creditor,
billMonth : props.month,
billYear: props.year,
billPrice: props.price
}});
}
return(
<TouchableHighlight onPress={() => goBillscreen()}>
<View style={styles.container}>
<Image source={{ uri: props.picture}} style={styles.photo} />
<Text style={styles.text}>
{`${props.type} ${props.creditor} / ${props.month} ${props.year}`}
{`\n${props.price} euros`}
</Text>
</View>
</TouchableHighlight>
);
The question is : How do I give my realm to the ListBillView to give the data like : 问题是:如何将我的领域提供给ListBillView以提供类似的数据:
this.state = {
dataSource: ds.cloneWithRows(datafromrealm)
};
and how can I give type, creditor, month, year and price to Row ? 以及如何给Row提供类型,债权人,月份,年份和价格?
Sorry for the long post I tried but I'm lost ! 对不起,我尝试了很长时间,但我迷路了!
Thanks for all ! 谢谢大家!
the question is not well defined but seems you are asking how to process data for every row in your listview. 这个问题的定义不明确,但似乎您在询问如何处理列表视图中每一行的数据。 You can check some of the examples we have in realm-js repo like this one 您可以检查一些在realm-js存储库中的示例,例如:
https://github.com/realm/realm-js/blob/master/examples/ReactExample/components/todo-listview.js#L85 https://github.com/realm/realm-js/blob/master/examples/ReactExample/components/todo-listview.js#L85
This is a todo list sample application which uses a ListView to show the todo items. 这是一个待办事项列表示例应用程序,它使用ListView显示待办事项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.