I have real troubles getting the dhx grid to show my json data that is returned from a simple web-api. Can anyone tell me what I am doing wrong?
Funny thing is, the header is drawn and so are the appropriate number of rows - however, there is no details printed in the rows - they all seem blank…???
Many thanks
Marcel
mygrid = new dhtmlXGridObject(‘gridbox’);
mygrid.setImagePath(“codebase/imgs”)
mygrid.setHeader(“Title,Producer,Price”);
mygrid.setInitWidths(“90, 90, 60”);
mygrid.setColSorting(“str,str,str”);
mygrid.setColTypes(“ed,ed,price”);
mygrid.setSkin(“light”);
mygrid.init();
var list1 = new dhtmlXDataStore(
{
url: “/api/Albums/GetAllAlbums3”,
datatype: “json”
});
mygrid.sync(list1);
---- asp - webapi below ----
public IEnumerable<Album> GetAllAlbums3()
{
return Albums.MyAlbums;
}
public class Album
{
public string Title { get; set; }
public string Producer { get; set; }
public double Price { get; set; }
}
** this list is returned with a number of these Album items
_list.Add(new Album { Title = "Calimero", Producer = "Ricky", Price = 10.66 });
_list.Add(new Album { Title = "Capricious", Producer = "Dolly", Price = 4.33 });
_list.Add(new Album { Title = "Cobacabena", Producer = "Ricky", Price = 1.6 });
etc - etc