Question

i need to pass a list of object to View from controller using Json , what the syntax of java-script to access the list objects and its properties then add them into data table ?

Pas de solution correcte

Autres conseils

In Controller You need use anonymous object to return json data

var result = // object which contain result
var jsonData = result.select(x=>new{
   PropertyA = x.A,
   PropertyB = x.B,
   PropertyC = x.C,
});

return Json(jsonData, JsonRequestBehavior.AllowGet)

In function javascript

success:function(data){
 $.each(data,function(i,data){
    //loop and insert your table
    data.PropertyA //get data  
})
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top