私はreactJSのJSONリストを解析したいと思っています。 は、ここで私はReactJSのJsonオブジェクトを解析する方法
public class ModelEmployee
{
public List<Employeelist> Employees { get; set; }
public int count { get; set; }
public int Pagenumber { get; set; }
}
public class Employeelist
{
public int EmployeeID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public int RoleId { get; set; }
public string RoleName { get; set; }
public List<string> Roles { get; set; }
}
を使用していたモデルですそして、私のコントローラは、これは私が
componentWillMount: function(){
var xhr = new XMLHttpRequest();
xhr.open('get', this.props.url, true);
xhr.onload = function() {
var response = JSON.parse(xhr.responseText);
this.setState({ result: response });
}.bind(this);
xhr.send();
},
render: function(){
var rows = [];
this.state.result.Employees.forEach(function (item) {
rows.push(<EmployeeRow key={item.EmployeeID} item={item }/>);
});
そのが働いていない各値
を抽出するためにReactJSコードにしようとしているものですpublic ActionResult Index(int pageNum = 1)
{
ModelEmployee model = new ModelEmployee();
model = new ModelEmployee();
model.Employees = FetchAllDevices(pageNum, 10);
model.count = (int)Math.Ceiling((float)_empService.TotalCount()/_pageSize);
model.Pagenumber = pageNum;
return Json(model,JsonRequestBehavior.AllowGet);
}
です。しかし、これでsetStateを変更すると、
this.setState({ result: response.Employees });
これは正常に動作し、従業員リストを通過できます。しかし、pagenumberとcount変数にはアクセスできません。これを整理するのを手伝ってもらえますか? ありがとうございます。