PDA

View Full Version : [CLOSED] Passing summary value from child grid to parent's grid



redi
Sep 09, 2014, 6:11 AM
Hi,
I got another question. I have a gridpanel 'GridPanel1' this is the parent grid, and 'GridPanel2' (the child grid). On the child grid there's a column named 'SMUDifference'. There are more than 1 child for each parent. I want to get the summary from the 'SMUDifference' from the child grid and pass the summary value to it's parent 'TotalSMU' column. How can I do that?

Thanks.






<head id="Head1" runat="server">
<title></title>

<script type="text/javascript" id="igClientScript">

var insertRecord = function () {
var grid = <%= GridPanel1.ClientID %>;
var total= grid.store.getCount();
grid.store.insert(total, {});
grid.getView().focusRow(total);
grid.editingPlugin.startEdit(grid.store.getAt(tota l), grid.columns[0]);
var sm = grid.getSelectionModel();
sm.select(total);
};

var addrowgrid2 = function(){

var total=this.up('gridpanel').store.getCount();
var sm=this.up('gridpanel').getSelectionModel();
this.up('gridpanel').store.insert(total,{});
var x = 1;
var newTotal = (total+1);
var dtSMUFinal = "";
var newStartTime = "";
this.up('gridpanel').store.each(function(record, index) {

//alert('total: ' + total+'newtotal: ' + newTotal+ ' index: '+ index+ ' x: '+ x);
if(x == total) {
if (record.data.StatusCode == 1 || record.data.StatusCode ==2) {
dtSMUFinal = countSMUFinal(record.data.StartTime,record.data.En dTime,record.data.SMUInitial);
}else{
dtSMUFinal = record.data.SMUInitial;
}
//alert(record.data.EndTime);
newStartTime = record.data.EndTime;
return false;
}
x++;
});

var item = this.up('gridpanel').store.getAt((newTotal-1));
item.set('SMUInitial',dtSMUFinal);
item.set('StartTime',newStartTime);
item.set('EndTime',newStartTime);

sm.select(total);
}

</script>
</head>
<body style="background-color: #DFE8F6">
<form id="form1" runat="server">
<div>
<table align="center" width="98%"><tr><td align="center">
<ext:ResourceManager ID="ResourceManager1" runat="server" Locale="Client" DirectMethodNamespace="ActProduction"/>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%-- Create Model --%>
<ext:Hidden ID="Hidden1" runat="server" />

<ext:Model ID="Model1" runat="server" Name="CLSEqpEvent" IDProperty="ActualEqpEventID">
<Fields>
<ext:ModelField Name="ActualProdID" Type="String" />
<ext:ModelField Name="ActualEqpEventID" Type="String" />
<ext:ModelField Name="TotalSMU" Type="Float" />
<ext:ModelField Name="Remarks" Type="String" />
</Fields>
<Associations>
<ext:HasManyAssociation Model="CLSEqpEventDet" Name="RPEventDet" ForeignKey="ActualEqpEventID" PrimaryKey="ActualEqpEventID" Autoload="True" />
</Associations>
</ext:Model>
<ext:Model ID="Model2" runat="server" Name="CLSEqpEventDet" IDProperty="ActualEqpEventDetailID">
<Fields>
<ext:ModelField Name="ActualEqpEventDetailID" Type="String" />
<ext:ModelField Name="ActualEqpEventID" Type="String" />
<ext:ModelField Name="ActualProdID" Type="String" />
<ext:ModelField Name="SMUInitial" Type="Float" />
<ext:ModelField Name="SMUFinal" Type="Float" />
<ext:ModelField Name="SMUDifference" Type="Float" />
</Fields>
<Proxy>
<ext:PageProxy>
<API Read="ActProduction.GetEqpEvent" />
</ext:PageProxy>
</Proxy>
</ext:Model>
<ext:Store ID="StoreEvent" runat="server" ModelName="CLSEqpEvent" />
<%-- End Model --%>
<asp:TextBox ID="wdtProdPeriodTextBox" runat="server" BorderStyle="None"
Visible="False" Width="16px"></asp:TextBox>

<span>Loading for Equipment</span> = <span id="iLoad">0</span>
<ext:TabPanel ID="tabActual" runat="server" >
<Items>
<ext:Panel ID="tabstatus" runat="server" Title="Equipment Event" Cls="loseborder">
<Items>
<ext:FormPanel
ID="Panel2"
runat="server"
Frame="true"
BodyPadding="10"
Anchor="100% 100%"
Cls="loseborder">
<Items>
<ext:GridPanel ID="GridPanel1" StoreID="StoreEvent" runat="server" fittoframe="true" AutoScroll="True" anchor="100% 100%" Height="400" Width="600">
<topbar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnAdd" runat="server" Text="Add" Icon="Add">
<Listeners>
<Click Fn="insertRecord" />
</Listeners>
</ext:Button>
<ext:ToolbarSeparator />
<ext:Button ID="btnDelete" runat="server" Text="Delete" Icon="Exclamation">
<Listeners>
<Click Handler="#{GridPanel1}.deleteSelected(); #{UserForm}.getForm().reset();" />
</Listeners>
</ext:Button>
<ext:ToolbarSeparator />
</Items>
</ext:Toolbar>
</topbar>
<ColumnModel ID="ColumnModel1" runat="server" DefaultSortable="false">
<Columns>
<ext:Column ID="Column11" runat="server" Text="ActualProdID" Width="100" DataIndex="ActualProdID" Hidden="True" />
<ext:Column ID="Column12" runat="server" Text="ActualEqpEventID" DataIndex="ActualEqpEventID" width="200" Hidden="True" >
</ext:Column>
<ext:Column ID="Column17" runat="server" Text="SMU Total" DataIndex="TotalSMU" Width="150">
<Renderer Fn="Ext.util.Format.numberRenderer('0,000.00')" />
</ext:Column>
<ext:Column ID="Column19" runat="server" Text="Remarks" DataIndex="Remarks" Width="150" Hidden="True">
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:RowExpander ID="RowExpander1" runat="server" SingleExpand="False">
<Component>
<ext:GridPanel ID="GridPanel2" runat="server" fittoframe="true" AutoScroll="True" MaxHeight="250" Width="500">
<TopBar>
<ext:Toolbar ID="Toolbar2" runat="server">
<Items>
<ext:Button ID="Button2" runat="server" Text="Add" Icon="Add">
<Listeners>
<Click Fn="addrowgrid2" />
</Listeners>
</ext:Button>
<ext:ToolbarSeparator />
<ext:Button ID="Button5" runat="server" Text="Delete" Icon="Exclamation">
<Listeners>
<Click Handler="this.up('gridpanel').deleteSelected(); #{UserForm}.getForm().reset();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel ID="ColumnModel2" runat="server" DefaultSortable="false">
<Columns>
<ext:Column ID="Column21" runat="server" Text="ActualEqpEventDetailID" Width="100" DataIndex="ActualEqpEventDetailID" Hidden="True"/>
<ext:Column ID="Column22" runat="server" Text="ActualEqpEventID" DataIndex="ActualEqpEventID" width="150" Hidden="True">
</ext:Column>
<ext:Column ID="Column23" runat="server" Text="ActualProdID" DataIndex="ActualProdID" Width="150" Hidden="True">
</ext:Column>
<ext:Column ID="Column24" runat="server" Text="SMU Initial" Width="100" DataIndex="SMUInitial">
<Renderer Fn="Ext.util.Format.numberRenderer('0,000.00')" />
<Editor>
<ext:NumberField ID="edSMUInitial" runat="server" AllowDecimals="true" DecimalPrecision="2" HideTrigger="True"/>
</Editor>
</ext:Column>
<ext:Column ID="Column25" runat="server" Text="SMU Final" DataIndex="SMUFinal" width="100" >
<Renderer Handler="if(record.data.StatusCode == 1 || record.data.StatusCode == 2){if (record.data.EndTime < record.data.StartTime) { return round(((record.data.EndTime - record.data.StartTime)/3600000 + 24) + record.data.SMUInitial,2);}else{ return round(((record.data.EndTime - record.data.StartTime )/3600000) + record.data.SMUInitial,2); } }else{ return round(record.data.SMUInitial,2); } " />
</ext:Column>
<ext:Column ID="Column26" runat="server" Text="Diff" DataIndex="SMUDifference" Width="50" >
<Renderer Handler=" if(record.data.StatusCode == 1 || record.data.StatusCode == 2){ if (record.data.EndTime < record.data.StartTime) { return round(((record.data.EndTime - record.data.StartTime)/3600000 + 24),2); } else { return round(((record.data.EndTime - record.data.StartTime )/3600000),2); } }else { return 0; } " />
</ext:Column>
</Columns>
</ColumnModel>
<Listeners>
<AfterRender Handler="this.bindStore(this.record.RPEventDet());" Delay="1" />
</Listeners>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1" />
</Plugins>
</ext:GridPanel>
</Component>
</ext:RowExpander>
<ext:CellEditing ID="CellEditing4" runat="server" ClicksToEdit="1">
<Listeners>
<BeforeEdit Handler="
if (e.value == null)
e.value = '';"></BeforeEdit>
</Listeners>
</ext:CellEditing>
</Plugins>
<View>
<ext:GridView ID="GridView2" runat="server" StripeRows="true">
<GetRowClass Fn="getRowClass" />
</ext:GridView>
</View>
</ext:GridPanel>
</Items>
</ext:FormPanel>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</td></tr></table>
</div>
</form>
</body>

Daniil
Sep 09, 2014, 2:14 PM
Hi @redi,

The code throws an error for me.

As for the requirement, I can say that there is no such the functionality built-in.


I want to get the summary from the 'SMUDifference' from the child grid and pass the summary value to it's parent 'TotalSMU' column

There are the "get" and "set" methods available for a record instance.