Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In the view I want to get the json data like this:
C#
[{"name":"NewWork",
 "data":[{"\/Date(1398787200000)\/",196},
          {"\/Date(1398009600000)\/",62},
          {"\/Date(1397836800000)\/",65}]
 },
{"name":"BeiJing",
"data":[{"\/Date(1398787200000)\/",106},
        {"\/Date(1398700800000)\/",100},
        {"\/Date(1398441600000)\/",61},
        {"\/Date(1398355200000)\/",86}]
 }]

So in the controller I define the class like these,and return `List<viewmodelcitydata>` but the return data format is not what I want.How can I change the controller ViewModelCityData?And the other question,in the view my json `data` need to be order by `X`,if I sort them in the controller,why do they not order in the view?I have to sort them again in the view.
C#
 public class ViewModelCityData
{
   public string name { get; set; }
  public List<Point> data { get; set; }
}

public class Point
{
    public DateTime X { get; set; }
    public int Y { get; set; }
}


 [{"name":"NewWork",
  "data":[{"X":"\/Date(1398787200000)\/","Y":196},
          {"X":"\/Date(1398009600000)\/","Y":62},
          {"X":"\/Date(1397836800000)\/","Y":65}]
        },
   {"name":"BeiJing",
   "data":[{"X":"\/Date(1398787200000)\/","Y":106},
           {"X":"\/Date(1398700800000)\/","Y":100},
           {"X":"\/Date(1398441600000)\/","Y":61},
           {"X":"\/Date(1398355200000)\/","Y":86}]}]
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900