Aug 24, 2012, 7:39 PM
[CLOSED] Dynamic form generation in 2.0
I used to have a form that was generated server side...worked great until I moved to 2.0. What is the change the get this working again?
Here is the server-side code:
And here is the markup:
Here is the server-side code:
[DirectMethod] public void RecreateForm(object o, DirectEventArgs e)
{
string[] date = e.ExtraParams["dateInfo"].Split(new string[] { "-" }, StringSplitOptions.None);
int portfolioId = Convert.ToInt32(this.hidPortfolioId.Text);
WPDBEntities ent = new WPDBEntities();
PortfolioCompany co = (from c in ent.PortfolioCompanies
where c.PortfolioCompanyId.Equals(portfolioId)
select c).FirstOrDefault();
var titles = ent.sp_getFinancialResultGrid(Convert.ToInt32(this.hidPortfolioId.Text), Convert.ToInt32(date[0].Replace("Q", string.Empty)), Convert.ToInt32(date[1]));
var form = new FormPanel
{
ID = "FormTaskPanel1",
// RenderFormElement = false,
Border = false,
AutoHeight = true,
AutoScroll = true,
// LabelWidth = 150,
// LabelAlign = LabelAlign.Left,
Padding = 5
};
foreach (var title in titles)
{
if (!title.IsCalc)
{
NumberField df = new NumberField();
df.FieldLabel = title.Title;
df.ID = "Control_" + title.PortfolioPerformanceTitleId.ToString();
df.Value = (title.Value == null) ? string.Empty : title.Value.ToString();
df.LabelStyle = (title.IsCalc) ? "font-style:italic;padding-left:8px" : "";
hidControlIds.Text += title.PerformanceDataId.ToString() + ":";
df.IDMode = IDMode.Explicit;
df.Listeners.Blur.Handler = string.Format("ClientSaveChanges(this.value,{0},{1});", (title.PerformanceDataId != null) ? title.PerformanceDataId.ToString() : "0", title.PortfolioPerformanceTitleId);
form.Items.Add(df);
}
}
this.pnl.Items.Clear();
form.Render(this.pnl , RenderMode.RenderTo);
}
And here is the markup:
<ext:Panel runat="server" ID="pnl" AutoHeight="true"> <TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Label runat="server" Text="Quarters:" Flat="true"></ext:Label>
<ext:ComboBox runat="server" ID="cmboQuarters">
<DirectEvents>
<Select OnEvent="RecreateForm">
<EventMask Msg="Fetching data..." MinDelay="0" ShowMask="true" Target="CustomTarget" CustomTarget="#{pnl}" />
<ExtraParams>
<ext:Parameter Name="dateInfo" Value="this.value" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:ComboBox>
<ext:Label ID="lbFYE" runat="server" Text="Fiscal Year End:" Flat="true" StyleSpec="padding-left:5px"></ext:Label>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
Last edited by Daniil; Aug 26, 2012 at 9:47 AM.
Reason: [CLOSED]