Mar 05, 2011, 2:59 PM
[CLOSED] MVC - buid a toolbar dynamically
Hi,
I'm trying to build dynamically a toolbar inside a Form using a controller action.
My problem is that I can not find a way to put the toolbar in the <TopBar>.
This is my view:
Bye,
Stefano
I'm trying to build dynamically a toolbar inside a Form using a controller action.
My problem is that I can not find a way to put the toolbar in the <TopBar>.
This is my view:
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<%@ 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 id="Head1" runat="server">
<title>Dynamic Toolbar</title>
<ext:ResourcePlaceHolder ID="MainResourcePlaceHolder" runat="server" />
<script type="text/javascript">
var initToolbar = function () {
Ext.net.DirectMethod.request({
url: "/Test/BuildToolbar",
cleanRequest: true,
params: {
containerId: 'FormPanel1'
}
});
};
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Window
ID="FormWindow"
runat="server"
Title="Build Toolbar"
CenterOnLoad="true"
Width="600"
Height="210"
X="50"
Y="50"
Padding="10"
Resizable="false"
Closable="false"
Layout="Fit">
<Items>
<ext:FormPanel
ID="FormPanel1"
runat="server"
Border="false"
MonitorValid="true"
BodyStyle="background-color:transparent;"
Layout="Form">
<Items>
<ext:TextField
ID="CompanyField"
runat="server"
MsgTarget="Side"
AllowBlank="false"
FieldLabel="Company"
Width="260"
/>
<ext:NumberField
ID="PriceField"
runat="server"
MsgTarget="Side"
AllowBlank="false"
FieldLabel="Price"
Width="260"
/>
</Items>
<Listeners>
<Render Handler="initToolbar();" />
</Listeners>
<%--
<TopBar>
<ext:Toolbar ID="MyToolbar" runat="server">
<Items>
.......
</Items>
</ext:Toolbar>
</TopBar>
--%>
</ext:FormPanel>
</Items>
</ext:Window>
</form>
</body>
</html>
and this is my controller action: public Ext.Net.MVC.AjaxResult BuildToolbar(string containerId)
{
Ext.Net.MVC.AjaxResult response = new Ext.Net.MVC.AjaxResult();
Toolbar tb = new Toolbar();
tb.ID = "MyToolbar";
tb.Items.Add(new Button
{
ID = "ToolbarButtonAdd",
Text = "Nuovo",
Icon = Icon.Add
});
tb.Items.Add(new Button
{
ID = "ToolbarButtonSave",
Text = "Salva",
Icon = Icon.Disk
});
// ??? how to build the toolbar inside the TopBar ???
response.Script = tb.ToScript(Ext.Net.RenderMode.RenderTo, containerId);
return response;
}
Could you suggest me the right way to accomplish this?Bye,
Stefano
Last edited by Daniil; Apr 09, 2011 at 12:47 PM.
Reason: [CLOSED]