I have a problem, or rather, I don't know how to do it.
Consider the JSON type data coming from the API extension as follows.
DATA:[
{
OrderNo:66753,
Orders:[
{
Code:F-EN-01,
Name:Test1,
Quantity: 100,
},
{
Code:F-EN-05,
Name:Test2,
Quantity: 505,
},
...
]},
{
OrderNo:66754,
Orders:[
{
Code:F-EN-03,
Name:TestOr1,
Quantity:2000,
},
{
Code:F-EN-09,
Name:TestOr2,
Quantity: 4500
},
...
]},
...
Imagine going this way. What I want to do is to show it on the screen by grouping it according to the OrderNo data. I have attached the picture for complete understanding. I can do this using foreach inside foreach but i don't know how i can do it in xamarin xml side. enter image description here Thanks for your help, keep up the good work.
We can use a structure like this in normal ASP .NET MVC:
public class OrderDetail
{
public string ProductCode {get;set;}
public string ProductPrice {get;set;}
public string ProductCount {get;set;}
}
public class Order
{
public string orderNo {get;set;}
public List<OrderDetail> orderDetails {get;set;}
}
List<Order> orderList=new List<Order>();
foreach (var item in orderList)
{
<h1> item.orderNo() <h1>
foreach (var orderDetail in item.orderDetails)
{
<td> orderDetail.ProductCode() <td>
<td> orderDetail.ProductPrice() <td>
<td> orderDetail.ProductCount() <td>
}
}
I can print a list of objects in ListView with xamarin, yes, but if there is a field with an array in the objects I print, how do I print it?
This is how I solved the problem.
show picture
My problem was that I could not print the list in the object to the screen.
"List orderDetails;" in "Order" object I had a fiel of type "orderDetails" that was my aim to print on the screen. I wanted a screen as seen in the picture.