Here is my problem, i have a observable list, i need to get the brand name from database using each “brand_id” from the list observable e.g
var list = Observable({"id":"3","customer_id":"2","brand_id":"22"}, {"id":"4","customer_id":"2","brand_id":"18"});
var brand_name = Observable(
brand_name = list.map(function(x){
hh = db.query("SELECT * FROM brands WHERE id=(?)", x.brand_id);
var r;
hh.forEach(function(param) {
r = param.name;
});
return r;
});
);
module.exports = {
list, brand_name
}
The UX
<Each Items="{list}">
<!-- Card -->
<Panel Color="#fefefe" MinHeight="50" Margin="10,0,10,10">
<Grid Columns="6*, 4*" Margin="10,5,10,0">
<StackPanel>
<Text Value="{customer_id}" Alignment="Left"></Text>
<Text Value="{brand_name}" Alignment="Left"></Text>
<Text Value="Quantity : 5000" Alignment="Left"></Text>
</StackPanel>
<Text Value="{total_amount}" TextWrapping="Wrap" FontSize="24" Alignment="CenterRight"></Text>
</Grid>
<DropShadow Distance="3" Size="-1" Angle="360" Color="#1188C9" />
</Panel>
<!-- Card -->
</Each>
What logic can i use to get the brand name and how do i display in it in the UX??