Hi,
I have a page with a RadGrid configured to bind with OData services as the source. I am able to hit the OData endpoint, get the desired data in the browser. However the data just doesn't show-up in the grid. The OData service returns a static list of objects. I can see the JSON in the browser's Response or Fiddler. I am clueless. I got till this point by referring to some of the sample available on Telerik, but this situation seems weird. Pasting my code aspx and OData service below.
ASPX:
<form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <telerik:RadGrid runat="server" AutoGenerateColumns="false" ID="grdEmployee"> <MasterTableView> <Columns> <telerik:GridBoundColumn UniqueName="Name" DataType="System.String" DataField="Name" HeaderText="Name"> </telerik:GridBoundColumn> </Columns> </MasterTableView> <ClientSettings> <DataBinding Location="http://localhost:55638/od/" ResponseType="JSON"> <DataService TableName="Employee" Type="OData" /> </DataBinding> </ClientSettings> </telerik:RadGrid></form>
OData Service:
public class EmployeeController : ODataController { // GET api/<controller> public IEnumerable<models.Employee> Get() { List<models.Employee> emp = new List<models.Employee>(); emp.Add(new models.Employee { ID = "1", Name = "Ariel Musaltov", Sex = "Male", Age = 38, Country = "Russia", Region = "Central", City = "Moscow", Salary = new models.Salary { Basic = 18000, InHand = 16670 } }); emp.Add(new models.Employee { ID = "2", Name = "Allan Friedman", Sex = "Male", Age = 24, Country = "U.S.A", Region = "West", City = "San Jose", Salary = new models.Salary { Basic = 22000, InHand = 18672 } }); emp.Add(new models.Employee { ID = "3", Name = "John Smith", Sex = "Male", Age = 35, Country = "U.S.A", Region = "West", City = "Seattle", Salary = new models.Salary { Basic = 39020, InHand = 32431 } }); return emp; }}
Model
namespace models{ public class Employee { public string ID { set; get; } public string Name { set; get; } public string Sex { set; get; } public string Country { set; get; } public int Age { set; get; } public string Region { set; get; } public string City { set; get; } public Salary Salary { set; get; } }}
I have attached 2 screenshots - 1 shows the grid does not reflect the data from the datasource (OData) and 2nd shows that the model data is received by the browser successfully.
