Mar 10, 2010, 12:23 PM
Add Ext JavaScript Component to Component
You can add any client-side component to another Container (such as Panel) but calling the .add() function on the Container and passing in an instance of the new child component.
This can be very helpful if you have a purely client-side ExtJS Component, such as some custom extension that might not be available yet as an server-side <ext:> Component.
The following sample demonstrates a simple scenario of configuring an <ext:Panel>, then adding a client-side only new Ext.Panel() on initial page load.
Example
The call to .doLayout() will instruct the Container to recalculate the layout of its inner components.
Hope this helps.
This can be very helpful if you have a purely client-side ExtJS Component, such as some custom extension that might not be available yet as an server-side <ext:> Component.
The following sample demonstrates a simple scenario of configuring an <ext:Panel>, then adding a client-side only new Ext.Panel() on initial page load.
Example
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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>Ext.NET Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<script type="text/javascript">
Ext.onReady(function () {
var form = new Ext.Panel({
title : "My Panel",
border : false,
padding : 5,
layout : "form",
items : [{
xtype : "textfield",
fieldLabel : "Name",
anchor : "100%"
}]
});
pnl.add(form);
pnl.doLayout();
});
</script>
<ext:Panel
ID="pnl"
runat="server"
Title="Example"
Height="185"
Width="350"
Layout="fit"
/>
</form>
</body>
</html>
The key to making the child Component render correctly is using the .add() function, and then call .doLayout() on the Parent Container. The call to .doLayout() will instruct the Container to recalculate the layout of its inner components.
Hope this helps.