Nov 05, 2010, 3:31 PM
Postback parameter duplication after call to Render()
Hi,
Iam having a very weird problem that is happening after a DirectEvent from a combobox in which calls TableGrid.Render()
The following happens:
Every time the Render() function is called a new DatabaseManagerModuleTableColumnsGrid_SM and DatabaseManagerModuleTableGrid_SM entry is added to the headers, any idea why?
DatabaseManagerModule.cs
Iam having a very weird problem that is happening after a DirectEvent from a combobox in which calls TableGrid.Render()
The following happens:
__EVENTTARGET=SingularityResourceManager&__EVENTARGUMENT=SelectedCellId%7Cevent%7CCellSelect&DatabaseManagerModuleDatabaseCombo_Value=mysql&DatabaseManagerModuleDatabaseCombo=mysql&DatabaseManagerModuleDatabaseCombo_SelIndex=1&DatabaseManagerModuleTableGrid_SM=&DatabaseManagerModuleTableGrid_SM=%7B%22RecordID%22%3A-15%2C%22Name%22%3A%22TableField%22%2C%22SubmittedValue%22%3A%22help_topic%22%2C%22RowIndex%22%3A8%2C%22ColIndex%22%3A0%7D&DatabaseManagerModuleTableColumnsGrid_SM=&DatabaseManagerModuleTableColumnsGrid_SM=&DatabaseManagerModuleTableColumnsGrid_SM=
DatabaseManagerModuleTableColumnsGrid_SM and DatabaseManagerModuleTableGrid_SM have multiple entries in the post back and this is causing problems since only one of them is loaded :SEvery time the Render() function is called a new DatabaseManagerModuleTableColumnsGrid_SM and DatabaseManagerModuleTableGrid_SM entry is added to the headers, any idea why?
DatabaseManagerModule.cs
using System;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using Button = Ext.Net.Button;
using Panel = Ext.Net.Panel;
using Parameter = Ext.Net.Parameter;
namespace Singularity
{
public class DatabaseManagerModule : ISingularityModule
{
private const string MODULE_ID = "DatabaseManagerModule";
private readonly string LAUNCHER_ID = string.Format("{0}Launcher", MODULE_ID);
private readonly string WINDOW_ID = string.Format("{0}Window", MODULE_ID);
public const string ApplicationName = "Database Manager";
public readonly Version ApplicationVersion = new Version(1, 0);
private DesktopWindow ApplicationWindow { get; set; }
private DesktopShortcut ApplicationDesktopShortcut { get; set; }
private DesktopModule ApplicationDesktopModule { get; set; }
private List<Control> ApplicationPageControls { get; set; }
private Panel WestPanel;
private Store TableStore;
private GridPanel TableGrid;
private Store DatabaseStore;
private ComboBox DatabaseCombo;
private Store TableColumnsStore;
private GridPanel TableColumnsGrid;
public DatabaseManagerModule(bool autorun, Desktop parent)
{
ApplicationPageControls = new List<Control>();
ApplicationDesktopModule = new DesktopModule
{
ModuleID = MODULE_ID,
WindowID = WINDOW_ID,
AutoRun = autorun,
Launcher =
{
ID = LAUNCHER_ID,
Text = ApplicationName,
Icon = Icon.Application,
}
};
ApplicationDesktopShortcut = new DesktopShortcut
{
ModuleID = MODULE_ID,
Text = string.Format("{0} v{1}", ApplicationName, ApplicationVersion),
IconCls = string.Format("ShortcutIcon {0}DesktopShortcutIcon", MODULE_ID),
};
parent.ResourceManager.RegisterIcon(Icon.Database);
parent.ResourceManager.RegisterIcon(Icon.DatabaseAdd);
parent.ResourceManager.RegisterIcon(Icon.DatabaseDelete);
parent.ResourceManager.RegisterIcon(Icon.ArrowUndo);
ApplicationWindow = new DesktopWindow
{
ID = WINDOW_ID,
Title = string.Format("{0} v{1}", ApplicationName, ApplicationVersion),
Icon = Icon.Database,
Width = 800,
Height = 400,
Layout = "fit",
Collapsible = true,
};
ApplicationWindow.Init += Window_Load;
}
private void Window_Load(object sender, EventArgs e)
{
if (ApplicationWindow.Items.Count == 0)
{
ApplicationWindow.SuspendScripting();
DatabaseStore = new Store
{
ID = string.Format("{0}DatabaseStore", MODULE_ID),
BaseParams =
{
new Parameter("Command", "GetDatabases", ParameterMode.Value),
},
Proxy =
{
new HttpProxy
{
Url = "DatabaseManagerHandler.ashx",
Method = HttpMethod.POST,
}
},
Reader =
{
new ArrayReader
{
Fields =
{
new RecordField("DatabaseName"),
}
}
},
};
DatabaseCombo = new ComboBox
{
ID = string.Format("{0}DatabaseCombo", MODULE_ID),
DisplayField = "DatabaseName",
ValueField = "DatabaseName",
Store =
{
DatabaseStore
}
};
DatabaseCombo.DirectSelect += DatabaseCombo_DirectSelect;
TableStore = new Store
{
ID = string.Format("{0}TableStore", MODULE_ID),
BaseParams =
{
new Parameter("Command", "GetDatabaseTables", ParameterMode.Value),
new Parameter("TargetDatabase", DatabaseCombo.SelectedItem.Text, ParameterMode.Value),
},
Proxy =
{
new HttpProxy
{
Url = "DatabaseManagerHandler.ashx",
Method = HttpMethod.POST,
}
},
Reader =
{
new ArrayReader
{
Fields =
{
new RecordField("TableField"),
}
}
},
};
TableGrid = new GridPanel
{
ID = string.Format("{0}TableGrid", MODULE_ID),
Title = "Tables",
AutoExpandColumn = "TableField",
Height = Unit.Pixel(350),
Store =
{
TableStore
},
ColumnModel =
{
Columns =
{
new Column
{
Header= "TableField",
DataIndex = "TableField",
ColumnID = "TableField",
}
}
},
SelectionModel =
{
new CellSelectionModel
{
ID = "SelectedCellId",
}
},
};
(TableGrid.SelectionModel.Primary as CellSelectionModel).DirectEvents.CellSelect.Event += CellSelected;
TableColumnsStore = new Store
{
ID = string.Format("{0}TableColumnsStore", MODULE_ID),
BaseParams =
{
new Parameter("Command", "GetTableColumns", ParameterMode.Value),
new Parameter("TargetDatabase", DatabaseCombo.SelectedItem.Text, ParameterMode.Value),
new Parameter("TargetTable", (TableGrid.SelectionModel.Primary as CellSelectionModel).SelectedCell.Value, ParameterMode.Value),
},
Proxy =
{
new HttpProxy
{
Url = "DatabaseManagerHandler.ashx",
Method = HttpMethod.POST,
}
},
Reader =
{
new JsonReader
{
Fields =
{
new RecordField("Field"),
new RecordField("Type"),
new RecordField("Null"),
new RecordField("Key"),
new RecordField("Default"),
new RecordField("Extra"),
}
}
},
};
TableColumnsGrid = new GridPanel
{
ID = string.Format("{0}TableColumnsGrid", MODULE_ID),
Title = "Table Columns",
AutoExpandColumn = "Field",
Store =
{
TableColumnsStore
},
ColumnModel =
{
Columns =
{
new Column
{
MenuDisabled = true,
DataIndex = "Field",
Header = "Field",
},
new Column
{
MenuDisabled = true,
DataIndex = "Type",
Header = "Type",
},
new BooleanColumn
{
MenuDisabled = true,
DataIndex = "Null",
Header = "Null",
TrueText = "YES",
FalseText = "NO",
},
new Column
{
MenuDisabled = true,
DataIndex = "Key",
Header = "Key",
},
new Column
{
MenuDisabled = true,
DataIndex = "Default",
Header = "Default",
},
new Column
{
MenuDisabled = true,
DataIndex = "Extra",
Header = "Extra",
},
}
},
};
WestPanel = new Panel
{
TopBar =
{
new Toolbar
{
Items =
{
new Button
{
ID = string.Format("{0}AddDatabaseButton", MODULE_ID),
StandOut = true,
Icon = Icon.DatabaseAdd,
ToolTip = "Add database",
},
new Button
{
ID = string.Format("{0}DeleteDatabaseButton", MODULE_ID),
StandOut = true,
Icon = Icon.DatabaseDelete,
ToolTip = "Delete database",
},
new Button
{
ID = string.Format("{0}DropDatabaseButton", MODULE_ID),
StandOut = true,
Icon = Icon.ArrowUndo,
ToolTip = "Empty database",
},
},
},
},
ID = string.Format("{0}WestPanel", MODULE_ID),
Title = "Databases",
Collapsible = true,
MinWidth = Unit.Pixel(170),
Border = false,
Layout = "fit",
Items =
{
DatabaseCombo,
TableGrid
},
};
WestPanel.DirectEvents.AutoDataBind = true;
WestPanel.DirectEvents.Resize.Event += Resize_Event;
ApplicationWindow.Items.Add(
new BorderLayout
{
West =
{
Split = true,
Items =
{
WestPanel
}
},
Center =
{
Items =
{
new Panel
{
ID = string.Format("{0}CenterPanel", MODULE_ID),
Layout = "fit",
ContentControls =
{
},
Items =
{
TableColumnsGrid
}
}
}
}
});
ApplicationWindow.ResumeScripting();
}
}
private void CellSelected(object sender, DirectEventArgs e)
{
TableColumnsStore.BaseParams["TargetDatabase"] = DatabaseCombo.SelectedItem.Text;
TableColumnsStore.BaseParams["TargetTable"] = (TableGrid.SelectionModel.Primary as CellSelectionModel).SelectedCell.Value;
TableColumnsStore.DataBind();
TableColumnsGrid.Render();
}
private void Resize_Event(object sender, DirectEventArgs e)
{
}
private void DatabaseCombo_DirectSelect(object sender, DirectEventArgs e)
{
TableStore.BaseParams["TargetDatabase"] = DatabaseCombo.SelectedItem.Text;
TableStore.DataBind();
TableGrid.DataBind();
TableGrid.Render();
}
public DesktopModule GetDesktopModule()
{
return ApplicationDesktopModule;
}
public DesktopWindow GetWindow()
{
return ApplicationWindow;
}
public DesktopShortcut GetDesktopShortcut()
{
return ApplicationDesktopShortcut;
}
public List<Control> GetPageControls()
{
return ApplicationPageControls;
}
}
}
Default.aspxusing System;
using System.Collections.Generic;
using System.Web.UI;
namespace Singularity
{
public partial class _Default : Page
{
private List<ISingularityModule> Modules;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Page_Init(object sender, EventArgs e)
{
Modules = new List<ISingularityModule>();
Modules.Add(new DatabaseManagerModule(false, SingularityDesktop));
foreach (ISingularityModule item in Modules)
{
Form.Controls.Add(item.GetWindow());
SingularityDesktop.Shortcuts.Add(item.GetDesktopShortcut());
SingularityDesktop.Modules.Add(item.GetDesktopModule());
}
}
}
}
Thanks in advance!