PDA

View Full Version : [CLOSED] Reproduce DataView



canbay
Apr 10, 2013, 9:04 AM
Hi!

When i expand the GridPanel1,my Store_Detail reload.After that i'm expanding different row in the GridPanel1.Therefore previous row is Collapse.
What should I do? Waiting for your help.

Thanks.



protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.Store1.DataSource = new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am", "Manufacturing" },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am", "Manufacturing" },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am", "Manufacturing" },
new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am", "Finance" },
new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am", "Services" },
new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am", "Services" },
new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am", "Manufacturing" },
new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am", "Services" },
new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am", "Finance" },
new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am", "Manufacturing" }
};
this.Store1.DataBind();
}
}
protected void Store_Detail_Refresh(object sender, StoreReadDataEventArgs e)
{
Store_Detail.DataSource = My_DataSource;
Store_Detail.DataBind();
}



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
var template = '<span style="color:{0};">{1}</span>';

var change = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value);
}

var pctChange = function (value) {
return Ext.String.format(template, (value > 0) ? "green" : "red", value + "%");
}
</script>
<style>
div.item-wrap {
float: left;
border: 1px solid transparent;
cursor: pointer;
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />

<h1>GridPanel with RowExpander Plugin</h1>

<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="RowExpander"
Collapsible="true"
AnimCollapse="true"
Icon="Table"
Width="600">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="price" Type="Float" />
<ext:ModelField Name="change" Type="Float" />
<ext:ModelField Name="pctChange" Type="Float" />
<ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
<ext:ModelField Name="industry" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" Text="Company" DataIndex="company" Flex="1" />
<ext:Column ID="Column2" runat="server" Text="Price" DataIndex="price">
<Renderer Format="UsMoney" />
</ext:Column>
<ext:Column ID="Column3" runat="server" Text="Change" DataIndex="change">
<Renderer Fn="change" />
</ext:Column>
<ext:Column ID="Column4" runat="server" Text="Change" DataIndex="pctChange">
<Renderer Fn="pctChange" />
</ext:Column>
<ext:DateColumn ID="DateColumn1" runat="server" Text="Last Updated" DataIndex="lastChange" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" TrackOver="true" EnableTextSelection="true" />
</View>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Multi" />
</SelectionModel>
<Plugins>
<ext:RowExpander ID="RowExpander1" runat="server">
<Listeners>
<Expand Handler="#{Store_Detail}.reload();" Delay="1" />
</Listeners>
<Component>
<ext:Container ID="Container1" runat="server">
<Items>
<ext:DataView ID="DataView1" runat="server" SingleSelect="true" EnableTextSelection="true" ItemSelector="div.item-wrap">
<Store>
<ext:Store ID="Store_Detail" runat="server" OnReadData="Store_Detail_Refresh">
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="Detail_ID" />
<ext:ModelField Name="Detail" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Tpl ID="Tpl1" runat="server">
<Html>
<div>
<tpl for=".">
<table width="500" style="border:1px solid darkblue; margin:5px; font: normal 11px/15px tahoma,arial,verdana,sans-serif; text-align: left">
<tr>
<td>
<b>Detail : </b>{Detail_ID}
</td>
</tr>
<tr>
<td>
<b>Detail : </b>{Detail}
</td>
</tr>
</table>
</tpl>
</div>
</Html>
</Tpl>
</ext:DataView>
</Items>
</ext:Container>
</Component>
</ext:RowExpander>
</Plugins>
</ext:GridPanel>
</form>
</body>
</html>

Daniil
Apr 10, 2013, 12:18 PM
Hi @canbay,

Please set up SingleExpand="false" for the RowExpander. With this mode you should not use IDs within a RowExpander's Component.