Hi! I'm trying to set a small example of binding a RadGrid to a JSON string but I'm not accomplishing it...
Javascript (function gets called on an item click):
Control.ascx
Control.ascx.cs
I based my code on the one i found on this post: http://www.telerik.com/community/forums/aspnet-ajax/grid/bind-radgrid-client-side-to-a-json-array.aspx
But, I'm getting the following Javascript exception:
On Chrome, I get:
On Firefox I get:
P.S.: I didn't add RadScriptManager because the portal already has a ScriptManager... Don't know if that is the problem...
Javascript (function gets called on an item click):
function FillTelerikGrid() { var GridData; GridData = "{\"Contacts\": {\"Contact\": [{\"ID\": \"1\",\"Name\": \"John Doe\",\"Age\": \"21\",\"Email\": \"johndoe@example.com\"}]}}"; var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); tableView.set_dataSource(GridData); tableView.dataBind();}Control.ascx
<div id="<%=this.ClientID%>_ContextContainer" class="divContextContainer" style="float: left; height: 400px; overflow-y: auto; width: 33.3%;"> <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" Skin="Metro"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div>Control.ascx.cs
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { dynamic data = new[] { new { ID = "1", Name ="Name11",Age = "0"}, new { ID = "2", Name ="Name11",Age = "0"}, new { ID = "3", Name ="Name11",Age = "0"}, new { ID = "4", Name ="Name11",Age = "0"} }; RadGrid1.MasterTableView.DataSource = data; RadGrid1.DataBind(); } } catch (Exception ex) { Platform.WebUI.DiagnosticsHelper.ReportError(ex); throw ex; } }I based my code on the one i found on this post: http://www.telerik.com/community/forums/aspnet-ajax/grid/bind-radgrid-client-side-to-a-json-array.aspx
But, I'm getting the following Javascript exception:
On Chrome, I get:
Uncaught TypeError: Cannot read property 'style' of null ScriptResource.axd:6507Telerik.Web.UI.RadGrid._getAllChildItemsRecursive ScriptResource.axd:6507Telerik.Web.UI.RadGrid._getPositionedDataItems ScriptResource.axd:6499Telerik.Web.UI.GridTableView.dataBind ScriptResource.axd:3831FillTelerikGrid Notes.aspx:695getContextView Notes.aspx:637(anonymous function) Notes.aspx:608f.event.dispatch jquery.js:3h.handle.iOn Firefox I get:
[21:29:29.778] TypeError: m.get_element(...).parentNode.parentNode is null @ https://www.....(...)P.S.: I didn't add RadScriptManager because the portal already has a ScriptManager... Don't know if that is the problem...