One to many - Load Failed OK

  1. #1

    One to many - Load Failed OK

    Hello everyone,

    Coolite is great, thank you guys!*
    Normally I found what I needed on the forums, but on this issue I got stuck.


    I have a page with two grids: parent and child. When I select a row in the parent grid(grid1), I would like to display the child records in the child grid(grid2). I prepare the data for the child grid fine, but when I bind it to its store, I get a Load Failed with an OK status.

    Please help.*


    Here is the code:


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="testPage02.aspx.cs" Inherits="testPages_testPage02" %>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    ** *<title>Untitled Page</title>
    ** *<script runat="server">
    ** * * *public class ParentClass
    ** * * *{
    ** * * * * *public string ParentID { get; set; }
    ** * * * * *public string ParentRecordField1 { get; set; }
    ** * * * * *public string ParentRecordField2 { get; set; }
    ** * * * * *public string ParentRecordField3 { get; set; }
    ** * * *}
    
    
    ** * * *public class ChildClass
    ** * * *{
    ** * * * * *public string ChildID { get; set; }
    ** * * * * *public string ParentID { get; set; }
    ** * * * * *public string ChildRecordField1 { get; set; }
    ** * * * * *public string ChildRecordField2 { get; set; }
    ** * * * * *public string ChildRecordField3 { get; set; }
    ** * * * * *public string ChildRecordField4 { get; set; }
    ** * * *}
    
    
    
    
    ** * * *protected void store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
    ** * * *{
    ** * * * * *List<ParentClass> parentList = new List<ParentClass>();
    ** * * * * *for (int i = 0; i < 10; i++)
    ** * * * * *{
    ** * * * * * * *parentList.Add(new ParentClass()
    ** * * * * * * *{
    ** * * * * * * * * *ParentID = i.ToString(),
    ** * * * * * * * * *ParentRecordField1 = "111",
    ** * * * * * * * * *ParentRecordField2 = "222",
    ** * * * * * * * * *ParentRecordField3 = "333"
    ** * * * * * * *});
    ** * * * * *}
    
    
    ** * * * * *store1.DataSource = parentList;
    ** * * * * *store1.DataBind();
    ** * * *}
    
    
    ** * * *protected void store2_RefreshData(object sender, StoreRefreshDataEventArgs e)
    ** * * *{
    ** * * * * *string parentID = e.Parameters["ParentID"];
    
    
    ** * * * * *if (parentID == "") return;
    
    
    ** * * * * *List<ChildClass> childList = new List<ChildClass>();
    ** * * * * *for (int i = 0; i < 15; i++)
    ** * * * * *{
    ** * * * * * * *childList.Add(new ChildClass()
    ** * * * * * * *{
    ** * * * * * * * * *ChildID = i.ToString(),
    ** * * * * * * * * *ParentID = parentID,
    ** * * * * * * * * *ChildRecordField1 = "aaaa",
    ** * * * * * * * * *ChildRecordField2 = "bbbb",
    ** * * * * * * * * *ChildRecordField3 = "cccc",
    ** * * * * * * * * *ChildRecordField4 = "dddd"
    ** * * * * * * *}
    ** * * * * * * *);
    ** * * * * *}
    
    
    ** * * * * *store2.DataSource = childList;
    ** * * * * *store2.DataBind();
    ** * * *} * * * * *
    ** *</script>
    </head>
    <body>
    ** *<form id="form1" runat="server">
    ** *<ext:ScriptManager ID="ScriptManager1" runat="server" CleanResourceUrl="false"
    ** * * *SourceFormatting="true">
    ** *</ext:ScriptManager>
    ** *<ext:Store runat="server" ID="store1" AutoLoad="true" RemoteSort="true" OnRefreshData="store1_RefreshData">
    ** * * *<Proxy>
    ** * * * * *<ext:DataSourceProxy />
    ** * * *</Proxy>
    ** * * *<Reader>
    ** * * * * *<ext:JsonReader ReaderID="reader1ID">
    ** * * * * * * *<Fields>
    ** * * * * * * * * *<ext:RecordField Name="ParentID" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField1" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField2" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField3" />
    ** * * * * * * *</Fields>
    ** * * * * *</ext:JsonReader>
    ** * * *</Reader>
    ** * * *<SortInfo Field="ParentRecordField1" Direction="ASC" />
    ** * * *<Listeners>
    ** * * * * *<LoadException Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
    ** * * *</Listeners>
    ** *</ext:Store>
    ** *<ext:Store runat="server" ID="store2" AutoLoad="true" RemoteSort="true" OnRefreshData="store2_RefreshData">
    ** * * *<Proxy>
    ** * * * * *<ext:DataSourceProxy />
    ** * * *</Proxy>
    ** * * *<Reader>
    ** * * * * *<ext:JsonReader ReaderID="reader2ID">
    ** * * * * * * *<Fields>
    ** * * * * * * * * *<ext:RecordField Name="ChildID" />
    ** * * * * * * * * *<ext:RecordField Name="ParentID" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField1" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField2" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField3" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField4" />
    ** * * * * * * *</Fields>
    ** * * * * *</ext:JsonReader>
    ** * * *</Reader>
    ** * * *<BaseParams>
    ** * * * * *<ext:Parameter Name="ParentID" Value="#{grid1}.getSelectionModel().hasSelection() ? #{grid1}.getSelectionModel().selections.items[0].data.ParentID : ''"
    ** * * * * * * *Mode="Raw" />
    ** * * *</BaseParams>
    ** * * *<SortInfo Field="ParentRecordField1" Direction="ASC" />
    ** * * *<Listeners>
    ** * * * * *<LoadException Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
    ** * * *</Listeners>
    ** *</ext:Store>
    ** *<ext:GridPanel runat="server" ID="grid1" StripeRows="true" StoreID="store1"
    ** * * *Title="Parent Grid" Header="true" Height="250">
    ** * * *<ColumnModel ID="ColumnModel1" runat="server">
    ** * * * * *<Columns>
    ** * * * * * * *<ext:Column Header="Parent ID" DataIndex="ParentID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field1" DataIndex="ParentRecordField1" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field2" DataIndex="ParentRecordField2" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field3" DataIndex="ParentRecordField3" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * *</Columns>
    ** * * *</ColumnModel>
    ** * * *<SelectionModel>
    ** * * * * *<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
    ** * * * * * * *<Listeners>
    ** * * * * * * * * *<RowSelect Handler="#{store2}.reload();" Buffer="250" />
    ** * * * * * * *</Listeners>
    ** * * * * *</ext:RowSelectionModel>
    ** * * *</SelectionModel>
    ** * * *<LoadMask ShowMask="true" />
    ** *</ext:GridPanel>
    ** *<ext:GridPanel runat="server" ID="grid2" StripeRows="true" StoreID="store2"
    ** * * *Title="Child Grid" Header="true" Height="250">
    ** * * *<ColumnModel ID="ColumnModel2" runat="server">
    ** * * * * *<Columns>
    ** * * * * * * *<ext:Column Header="Parent ID" DataIndex="ParentID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Child ID" DataIndex="ChildID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field1" DataIndex="ChildRecordField1" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field2" DataIndex="ChildRecordField2" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field3" DataIndex="ChildRecordField3" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field4" DataIndex="ChildRecordField4" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * *</Columns>
    ** * * *</ColumnModel>
    ** * * *<SelectionModel>
    ** * * * * *<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
    ** * * * * *</ext:RowSelectionModel>
    ** * * *</SelectionModel>
    ** * * *<LoadMask ShowMask="true" />
    ** *</ext:GridPanel>
    ** *
    ** *</form>
    </body>
    </html>

    Thanks in advance!






  2. #2

    RE: One to many - Load Failed OK

    Hi,

    1. Set AutoLoad="false" for second store
    2. In*store2_RefreshData set to DataSource empty*List<ChildClass> instead make return when ParentID is absent
    3. reader1ID and reader2ID is absent in your objects. You must specify existing properties in ReaderID


  3. #3

    RE: One to many - Load Failed OK

    Thanks Vlad!

    It all worked fine. I would like to post the fixed code, if anyone is interested.
    Here it is:


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="testPage02.aspx.cs" Inherits="testPages_testPage02" %>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <%@ Import Namespace="System.Collections.Generic"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    ** *<title>Untitled Page</title>
    ** *<script runat="server">
    ** * * *public class ParentClass
    ** * * *{
    ** * * * * *public string ParentID { get; set; }
    ** * * * * *public string ParentRecordField1 { get; set; }
    ** * * * * *public string ParentRecordField2 { get; set; }
    ** * * * * *public string ParentRecordField3 { get; set; }
    ** * * *}
    
    
    ** * * *public class ChildClass
    ** * * *{
    ** * * * * *public string ChildID { get; set; }
    ** * * * * *public string ParentID { get; set; }
    ** * * * * *public string ChildRecordField1 { get; set; }
    ** * * * * *public string ChildRecordField2 { get; set; }
    ** * * * * *public string ChildRecordField3 { get; set; }
    ** * * * * *public string ChildRecordField4 { get; set; }
    ** * * *}
    
    
    
    
    ** * * *protected void store1_RefreshData(object sender, StoreRefreshDataEventArgs e)
    ** * * *{
    ** * * * * *List<ParentClass> parentList = new List<ParentClass>();
    ** * * * * *for (int i = 0; i < 10; i++)
    ** * * * * *{
    ** * * * * * * *parentList.Add(new ParentClass()
    ** * * * * * * *{
    ** * * * * * * * * *ParentID = i.ToString(),
    ** * * * * * * * * *ParentRecordField1 = "111",
    ** * * * * * * * * *ParentRecordField2 = "222",
    ** * * * * * * * * *ParentRecordField3 = "333"
    ** * * * * * * *});
    ** * * * * *}
    
    
    ** * * * * *store1.DataSource = parentList;
    ** * * * * *store1.DataBind();
    ** * * *}
    
    
    ** * * *protected void store2_RefreshData(object sender, StoreRefreshDataEventArgs e)
    ** * * *{
    ** * * * * *string parentID = e.Parameters["ParentID"];
    ** * * * * *List<ChildClass> childList = new List<ChildClass>();
    
    
    ** * * * * *if (parentID != "")
    ** * * * * *{
    ** * * * * * * *for (int i = 0; i < 15; i++)
    ** * * * * * * *{
    ** * * * * * * * * *childList.Add(new ChildClass()
    ** * * * * * * * * *{
    ** * * * * * * * * * * *ChildID = i.ToString(),
    ** * * * * * * * * * * *ParentID = parentID,
    ** * * * * * * * * * * *ChildRecordField1 = "aaaa",
    ** * * * * * * * * * * *ChildRecordField2 = "bbbb",
    ** * * * * * * * * * * *ChildRecordField3 = "cccc",
    ** * * * * * * * * * * *ChildRecordField4 = "dddd"
    ** * * * * * * * * *}
    ** * * * * * * * * *);
    ** * * * * * * *}
    ** * * * * *}
    ** * * * * *store2.DataSource = childList;
    ** * * * * *store2.DataBind();
    ** * * *} * * * * *
    ** *</script>
    </head>
    <body>
    ** *<form id="form1" runat="server">
    ** *<ext:ScriptManager ID="ScriptManager1" runat="server" CleanResourceUrl="false"
    ** * * *SourceFormatting="true">
    ** *</ext:ScriptManager>
    ** *<ext:Store runat="server" ID="store1" AutoLoad="true" RemoteSort="true" OnRefreshData="store1_RefreshData">
    ** * * *<Proxy>
    ** * * * * *<ext:DataSourceProxy />
    ** * * *</Proxy>
    ** * * *<Reader>
    ** * * * * *<ext:JsonReader ReaderID="ParentID">
    ** * * * * * * *<Fields>
    ** * * * * * * * * *<ext:RecordField Name="ParentID" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField1" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField2" />
    ** * * * * * * * * *<ext:RecordField Name="ParentRecordField3" />
    ** * * * * * * *</Fields>
    ** * * * * *</ext:JsonReader>
    ** * * *</Reader>
    ** * * *<SortInfo Field="ParentRecordField1" Direction="ASC" />
    ** * * *<Listeners>
    ** * * * * *<LoadException Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
    ** * * *</Listeners>
    ** *</ext:Store>
    ** *<ext:Store runat="server" ID="store2" AutoLoad="false" RemoteSort="true" OnRefreshData="store2_RefreshData">
    ** * * *<Proxy>
    ** * * * * *<ext:DataSourceProxy />
    ** * * *</Proxy>
    ** * * *<Reader>
    ** * * * * *<ext:JsonReader ReaderID="ChildID">
    ** * * * * * * *<Fields>
    ** * * * * * * * * *<ext:RecordField Name="ChildID" />
    ** * * * * * * * * *<ext:RecordField Name="ParentID" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField1" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField2" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField3" />
    ** * * * * * * * * *<ext:RecordField Name="ChildRecordField4" />
    ** * * * * * * *</Fields>
    ** * * * * *</ext:JsonReader>
    ** * * *</Reader>
    ** * * *<BaseParams>
    ** * * * * *<ext:Parameter Name="ParentID" Value="#{grid1}.getSelectionModel().hasSelection() ? #{grid1}.getSelectionModel().selections.items[0].data.ParentID : ''"
    ** * * * * * * *Mode="Raw" />
    ** * * *</BaseParams>
    ** * * *<SortInfo Field="ParentRecordField1" Direction="ASC" />
    ** * * *<Listeners>
    ** * * * * *<LoadException Handler="Ext.MessageBox.alert('Load failed', response.statusText);" />
    ** * * *</Listeners>
    ** *</ext:Store>
    ** *<ext:GridPanel runat="server" ID="grid1" StripeRows="true" StoreID="store1"
    ** * * *Title="Parent Grid" Header="true" Height="250">
    ** * * *<ColumnModel ID="ColumnModel1" runat="server">
    ** * * * * *<Columns>
    ** * * * * * * *<ext:Column Header="Parent ID" DataIndex="ParentID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field1" DataIndex="ParentRecordField1" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field2" DataIndex="ParentRecordField2" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field3" DataIndex="ParentRecordField3" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * *</Columns>
    ** * * *</ColumnModel>
    ** * * *<SelectionModel>
    ** * * * * *<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">
    ** * * * * * * *<Listeners>
    ** * * * * * * * * *<RowSelect Handler="#{store2}.reload();" Buffer="250" />
    ** * * * * * * *</Listeners>
    ** * * * * *</ext:RowSelectionModel>
    ** * * *</SelectionModel>
    ** * * *<LoadMask ShowMask="true" />
    ** *</ext:GridPanel>
    ** *<ext:GridPanel runat="server" ID="grid2" StripeRows="true" StoreID="store2"
    ** * * *Title="Child Grid" Header="true" Height="250">
    ** * * *<ColumnModel ID="ColumnModel2" runat="server">
    ** * * * * *<Columns>
    ** * * * * * * *<ext:Column Header="Parent ID" DataIndex="ParentID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Child ID" DataIndex="ChildID" Sortable="false" Width="50">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field1" DataIndex="ChildRecordField1" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field2" DataIndex="ChildRecordField2" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field3" DataIndex="ChildRecordField3" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * * * *<ext:Column Header="Field4" DataIndex="ChildRecordField4" Sortable="false" Width="60">
    ** * * * * * * *</ext:Column>
    ** * * * * *</Columns>
    ** * * *</ColumnModel>
    ** * * *<SelectionModel>
    ** * * * * *<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
    ** * * * * *</ext:RowSelectionModel>
    ** * * *</SelectionModel>
    ** * * *<LoadMask ShowMask="true" />
    ** *</ext:GridPanel>
    ** *
    ** *</form>
    </body>
    </html>

    Cheers!

Similar Threads

  1. Failed to load resource
    By tuananhdnx in forum 1.x Help
    Replies: 3
    Last Post: Dec 27, 2011, 1:26 PM
  2. Replies: 3
    Last Post: Jun 04, 2011, 9:23 AM
  3. Replies: 1
    Last Post: Mar 16, 2011, 9:56 PM
  4. [CLOSED] Load failed: Unexpected token <
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 02, 2010, 5:58 PM
  5. [CLOSED] Failed to load viewstate
    By sharif in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 20, 2010, 5:22 PM

Posting Permissions