PDA

View Full Version : [CLOSED] how to hand over child window's data to the parents sheet's field



rockhome
Jan 15, 2015, 11:54 PM
Dear all,
I can't solve the problem how to hand over child window's row data to the parents sheet's field.
Below, there are two sample source.
One is parents sheet, and another is child modal window made by GridPanel.
In the example, child window's row-selected data(deptcd) gridpanel hand over when that row data is double-clicked or row-command icon clicked.
So, I need two solution :
1. how to hand over when child selected-row is double-clicked.
2. how to hand over when child row-command icon is clicked.

[Parents Page Code]


<script runat="server">
protected void DeptCodeHelper(object sender, DirectEventArgs e)
{
UserControlRendererConfig config = new UserControlRendererConfig
{
UserControlPath = "DeptCodeHelper.ascx",
SingleControl = true,
Mode = RenderMode.RenderTo,
Element = this.Form.ClientID
};

config.BeforeRender += delegate(ComponentAddedEventArgs ce)
{
ce.Control.ID = BaseControl.GenerateID();
e.ExtraParamsResponse.Add(new Ext.Net.Parameter("windowId", ce.Control.ConfigID));
};

UserControlRenderer.Render(config);
}
</script>

<ext:ResourceManager ID="ResourceManager1" runat="server" DirectMethodNamespace="CompanyX"/>

<ext:FormPanel ID="FormPanel1" runat="server" title="Department" Frame="true" Width="400" ButtonAlign="left" >
<FieldDefaults LabelAlign="Left" LabelWidth="100" />
<Items>
<ext:FieldContainer ID="FieldContainer1" runat="server" Layout="HBoxLayout">
<Items>
<ext:TextField ID="ctlDeptNm" runat="server" FieldLabel="DeptCode" AllowBlank="True"/>
<ext:Button ID="Button2" runat="server" Icon="Magnifier">
<DirectEvents>
<Click OnEvent="DeptCodeHelper" Single="true" />
</DirectEvents>
</ext:Button>
</Items>
</ext:FieldContainer>
<ext:Container ID="Container1" runat="server">
<Items>
<ext:TextField ID="ctlDeptCd" runat="server" FieldLabel="DeptCode" AllowBlank="false" />
</Items>
</ext:Container>
</Items>
</ext:FormPanel>


[Child Window Code]


<ext:Window ID="Window1" runat="server" Title="CodeHelper" Width="400" Height="400"
MinWidth="300" MinHeight="300" Layout="FitLayout" Resizable="true" Modal="true">
<Items>
<ext:FormPanel ID="FormPanel2" runat="server" Border="false" AutoDoLayout="true" BodyPadding="10">
<Content>
<ext:GridPanel ID="GridPanel2" runat="server" Width="370" Height="310">
<Store>
<ext:Store ID="Store2" runat="server">
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="DeptCd" Type="String"/>
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>

<ext:Column ID="Column1" runat="server" Text="DeptCode" DataIndex="DeptCd" Width="60" />
<ext:CommandColumn ID="CommandColumn2" runat="server" Width="20">
<Commands>
<ext:GridCommand Icon="Add" CommandName="Detail" />
</Commands>
<DirectEvents>
<Command OnEvent="btnSelect">
<ExtraParams>
<ext:Parameter Name="cmd" Value="command" Mode="Raw" />
<ext:Parameter Name="data" Value="record.data.DeptCd" Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>

</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" >
<Listeners></Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Content>
</ext:FormPanel>
</Items>
</ext:Window>

Daniil
Jan 16, 2015, 7:41 AM
Hi @rockhome,


1. how to hand over when child selected-row is double-clicked.

There is a ItemDblClick even on a GridPanel. Probably, you could try to use it.


2. how to hand over when child row-command icon is clicked.

You already set up a Command DirectEvent on the CommandColumn. Does it not work as you need? I guess it doesn't, because a DirectEvent should not be working in such a scenario. You render the User Control control dynamically. If you don't recreate that User control on each request, then DirectEvents cannot work. Any DirectEvent requires a control instance on server.

I think you could use a client side Listener and do everything in JavaScript.