PDA

View Full Version : [CLOSED] summarycolumn didn't recalculate automatically when data is inserted directly into the store



CarpFisher
Jun 04, 2012, 4:31 PM
It seems that the summarycolumn didn't recalculate automatically when data is inserted into the store. How to force the summarycolumn to recalculate manually?

Here is the code to reproduce the problem:



<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">

[DirectMethod]
public void add()
{
strColInst.Insert(0, new { instName = "abc", amount = 101.10, instPerc = 10, instCode = "a1" });
}

</script>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:GridPanel ID="Panel4" runat="server" Title="Instruments" Border="false" Layout="FitLayout" Icon="PackageAdd" Selectable="true">

<View>
<ext:GridView ID="GridView1" runat="server" LoadMask="true" LoadingText="Loading..." />
</View>
<Store>
<ext:Store ID="strColInst" runat="server" >

<Model>
<ext:Model ID="Model1" runat="server" IDProperty="instCode">
<Fields>

<ext:ModelField Name="instCode" />
<ext:ModelField Name="instName" />
<ext:ModelField Name="amount" Type="Float"/>
<ext:ModelField Name="instPerc" Type="Float" />

</Fields>
</ext:Model>
</Model>

</ext:Store>
</Store>
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>

<ext:Column ID="Column1" runat="server" Text="Instrument Name" DataIndex="instName" Flex="1">
</ext:Column>

<ext:SummaryColumn ID="SummaryColumn1" runat="server" Text="Amount" Width="90" DataIndex="amount" SummaryType="Sum">
<SummaryRenderer Handler="return Ext.util.Format.number(value, '0,000.00');" ></SummaryRenderer>

</ext:SummaryColumn>
<ext:SummaryColumn ID="Column5" runat="server" Text="%" DataIndex="instPerc" Width="30" SummaryType="Sum">
<SummaryRenderer Handler="return Ext.util.Format.number(value, '00');" ></SummaryRenderer>
</ext:SummaryColumn>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="sumInst" runat="server" />

</Features>
<SelectionModel>
<ext:RowSelectionModel ID="ExtInvSelectionModel" runat="server" Mode="Single" />
</SelectionModel>
<Buttons>
<ext:Button Icon="Add" ID="btnAddInst" Text="Add New" runat="server" >
<Listeners>
<Click Handler="App.direct.add()"></Click>
</Listeners>

</ext:Button>
<ext:Button Icon="Delete" ID="btnDelInst" Text="Delete" runat="server" >

<Listeners>

</Listeners>

</ext:Button>

</Buttons>

</ext:GridPanel>
</form>
</body>
</html>

Daniil
Jun 04, 2012, 7:23 PM
Hi,

Please call

GridView1.Refresh();
after inserting a row.

CarpFisher
Jun 07, 2012, 8:28 AM
Thanks it works.

I think my problem is I don't know which object to refresh.....Thanks again