PDA

View Full Version : [CLOSED] Find parent panel id using javascript



Maitreya
Nov 25, 2013, 10:36 AM
Hi,

Is there anyway to find a field's parent panel Id using JavaScript?

Example: In my case, I need to find "tabToFind" ext panel using txtName field. It has been wrapped using a form panel and another ext panel (used to group user control fields).

.Aspx page:
-------------


<ext:Panel runat="server" ID="tabToFind">
<Content>
<custom:UserControl ID="csUC" runat="server" />
</Content>
</ext:Panel>

User control (custom:UserControl - .ascx page):
----------------------------------------


<ext:Panel ID="tabOuterPanel" runat="server">
<Content>
<ext:FormPanel ID="formPanel" runat="server" >
<Items>
<ext:TextField ID="txtName" runat="server" FieldLabel="Name" />
</Items>
</ext:FormPanel>
</Content>
</ext:Panel>

Daniil
Nov 25, 2013, 2:33 PM
Hi @Maitreya,

Are you restricted to use Content? It is hard to achieve your requirement in this case.

If you are not restricted and can do the following:

1. Set up Layout="AutoLayout" for the tabToFind or any other layout (or use Items instead of Content and UserControlLoader instead of user control.

<ext:Panel runat="server" ID="tabToFind" Layout="AutoLayout">
<Content>
<custom:UserControl id="csUC" runat="server" />
</Content>
</ext:Panel>

2. Replace Content with Items here:

<ext:Panel ID="tabOuterPanel" runat="server">
<Items>
...
</Items>
</ext:Panel>

In this case the code to find the first Panel "outside the user control" can look something like this. (I wrote in quotes, because client side doesn't know anything about user controls).

var c,
field = App.csUC_txtName;

c = field;
do {
c = c.up("panel");
}
while (Ext.net.StringUtils.startsWith(c.id, "csUC"))

c.id