//Initialize ListView component
let remoteListObj: ListView = new ListView({
//Initialize dataSource with the DataManager instance.
dataSource: new DataManager({
adaptor: new WebApiAdaptor(),
crossDomain: true
//offline: true
}),
//Map the appropriate columns to fields property
fields: { id: "id", text: "name", child: "child" },
//Set header title
headerTitle: "Products",
//Set true to show header title
showHeader: true
});
//Render initialized ListView component
remoteListObj.appendTo("#listview");
[HttpGet]
public object Get()
{
// Get the DataSource from Database
var data = WeatherForecast.GetAllRecords().ToList();
return data;
}
public class WeatherForecast
{
public static List<WeatherForecast> order = new List<WeatherForecast>();
public static List<WeatherForecast> order1 = new List<WeatherForecast>();
public WeatherForecast()
{
}
public WeatherForecast(int id, string name, List<WeatherForecast> child)
{
this.id = id;
this.name = name;
this.child = child;
}
public static List<WeatherForecast> GetAllRecords()
{
if (order.Count == 0)
{
order1.Add(new WeatherForecast(6, "Child", null));
order.Add(new WeatherForecast(1, "Africa", order1));
order.Add(new WeatherForecast(2, "Asia", order1));
order.Add(new WeatherForecast(3, "Europe", null));
order.Add(new WeatherForecast(4, "India", null));
order.Add(new WeatherForecast(5, "Italy", null));
order.Add(new WeatherForecast(6, "China", null));
}
return order;
}
public int id { get; set; }
public string name { get; set; }
public List<WeatherForecast> child { get; set; }
} |