Mar 23, 2009, 1:08 PM
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:
Thanks in advance!
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!