Oct 05, 2009, 12:07 PM
Refresh Grid Panel when Window User Control is hidden
Hi
I'm currently loading a user control by clicking on a button. When the User control is hidden, I want to update the parent Grid panel and display the data which was entered in the UC window. I've tried hooking into the hide event without success and I've also tried <hide autopostback="true"> listner which also gives me errors not to mention resets my comboList.
The question I have is
1 - Am I loading the user control correctly?
2 - How can I refresh the girdpanel when the form is hidden / closed - ideally closed
Thanks
Ash
User Control ascx
I'm currently loading a user control by clicking on a button. When the User control is hidden, I want to update the parent Grid panel and display the data which was entered in the UC window. I've tried hooking into the hide event without success and I've also tried <hide autopostback="true"> listner which also gives me errors not to mention resets my comboList.
The question I have is
1 - Am I loading the user control correctly?
2 - How can I refresh the girdpanel when the form is hidden / closed - ideally closed
Thanks
Ash
User Control ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="UCAddEditStudyProtocol.ascx.cs" Inherits="UCAddEditStudyProtocol" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<ext:Window
ID="windowAddEditStudyProtocol"
runat="server"
Icon="Pencil"
Title="Add / Edit Study Protocol"
Showonload="false"
Width="350"
Height="350"
BodyStyle="padding:15px;"
Resizable="false"
Draggable="true"
Modal="true"
Centeronload="true"
Closable="false"
>
<Body>
<ext:FormLayout ID="frmAddEditStudyProtocol" runat="server" LabelWidth="135">
<Anchors>
<ext:Anchor>
<ext:ComboBox ID="comboBoxSampleTypeCategory" runat="server" FieldLabel="Sample Type Category" Editable="false">
</ext:ComboBox>
</ext:Anchor>
<ext:Anchor>
<ext:ComboBox ID="comboBoxProtocolType" runat="server" FieldLabel="Protocol Type" Editable="false">
</ext:ComboBox>
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtMinOccurance" runat="server" FieldLabel="Min Occurance" Regex="[0-9]" RegexText="Field can only contain numeric values">
</ext:TextField>
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtMaxOccurance" runat="server" FieldLabel="Max Occurance" Regex="[0-9]" RegexText="Field can only contain numeric values">
</ext:TextField>
</ext:Anchor>
<ext:Anchor>
<ext:ComboBox ID="comboBoxOccuranceFrequency" runat="server" FieldLabel="Occurance Frequency" Editable="false">
</ext:ComboBox>
</ext:Anchor>
<ext:Anchor>
<ext:TextField ID="txtOccuranceStart" runat="server" FieldLabel="Occurance Start" Regex="[0-9]" RegexText="Field can only contain numeric values">
</ext:TextField>
</ext:Anchor>
<ext:Anchor>
<ext:ComboBox ID="comboBoxOccuranceStartType" runat="server" FieldLabel="Occurance Start Type" Editable="false">
</ext:ComboBox>
</ext:Anchor>
</Anchors>
</ext:FormLayout>
</Body>
<Buttons>
<ext:Button ID="btnSave" runat="server" Text="Save">
<AjaxEvents>
<Click OnEvent="Save" >
<EventMask ShowMask="true" MinDelay="1000" Msg="Saving..." />
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnCancel" runat="server" Text="Cancel">
<AjaxEvents>
<Click OnEvent="Cancel">
</Click>
</AjaxEvents>
</ext:Button>
</Buttons>
</ext:Window>
User Control code-behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Coolite.Ext.Web;
public partial class UCAddEditStudyProtocol : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
this.windowAddEditStudyProtocol.ShowOnLoad = ShowForm;
}
public bool ShowForm { get; set; }
public Window WindowAddEditStudyProtocol
{
get
{
return windowAddEditStudyProtocol;
}
}
[AjaxMethod]
protected void Cancel(Object sender, AjaxEventArgs e)
{
this.windowAddEditStudyProtocol.Hide();
}
[AjaxMethod]
protected void Save(Object sender, AjaxEventArgs e)
{
this.windowAddEditStudyProtocol.Hide();
}
}
Main page
<ext:Tab ID="tabTrialAdministration" runat="server" Title="Admin" Border="false">
<Body>
<ext:RowLayout ID="RowLayout1" runat="server" Split="true">
<ext:LayoutRow RowHeight="0.1">
<ext:Panel ID="Panel2" runat="server" Title="Trials" BodyStyle="padding:15px;">
<Body>
<ext:FormLayout runat="server">
<anchors>
<ext:Anchor>
<ext:ComboBox ID="comboBoxStudies"
runat="server"
FieldLabel="Studies"
ReadOnly="true"
EmptyText="Select a Translational Study"
Editable="false">
<AjaxEvents>
<Select OnEvent="LoadStudyProtocols">
<EventMask ShowMask="true" />
<ExtraParams>
<ext:Parameter Name="Id" Value="this.getValue()" Mode="Raw" />
</ExtraParams>
</Select>
</AjaxEvents>
</ext:ComboBox>
</ext:Anchor>
</anchors>
</ext:FormLayout>
</Body>
</ext:Panel>
</ext:LayoutRow>
<ext:LayoutRow RowHeight="0.45">
<ext:GridPanel
ID="gridPanelStudyProtocols"
runat="server"
StoreID="storeStudyProtocols"
StripeRows="true"
Border="false"
AutoExpandColumn="SampleTypeCategoryID">
<ColumnModel ID="gridPanelStudyProtocolsColumnModel" runat="server">
<Columns>
<ext:Column Header="Sample Type Category" DataIndex="SampleTypeCategoryID" ColumnID="SampleTypeCategoryID" Width="0.15" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Protocol Type" DataIndex="ProtocolTypeID" Width="0.15" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Min Occurance" DataIndex="MinOccurance" Width="0.05" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Max Occurance" DataIndex="MaxOccurance" Width="0.05" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Occurance Frequency" DataIndex="OccuranceTypeID" Width="0.15" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Occurance Start" DataIndex="OccuranceStart" Width="0.05" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:Column Header="Occurance Start Type" DataIndex="OccuranceStartTypeID" Sortable="false" MenuDisabled="true" Fixed="true">
</ext:Column>
<ext:CommandColumn Width="60">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Delete">
<ToolTip Text="Delete" />
</ext:GridCommand>
<ext:CommandSeparator />
<ext:GridCommand Icon="NoteEdit" CommandName="Edit">
<ToolTip Text="Edit" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="gridPanelStudyProtocolsRowSelectionModel" runat="server" />
</SelectionModel>
<LoadMask ShowMask="true" />
<Buttons>
<ext:Button ID="btnSaveStudyProtocols" runat="server" Text="Save" Icon="Disk" Enabled="false">
<AjaxEvents>
<Click OnEvent="SaveStudyProtocols">
<EventMask ShowMask="true" />
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnInsertStudyProtocols" runat="server" Text="Insert" Icon="Add" Enabled="false">
<AjaxEvents>
<Click OnEvent="AddStudyProtocol">
<EventMask ShowMask="true" />
</Click>
</AjaxEvents>
</ext:Button>
<ext:Button ID="btnRefreshStudyProtocols" runat="server" Text="Refresh" Icon="ArrowRefresh" Enabled="false">
<AjaxEvents>
<Click OnEvent="RefreshStudyProtocols">
<EventMask ShowMask="true" />
</Click>
</AjaxEvents>
</ext:Button>
</Buttons>
<AjaxEvents>
<CellClick OnEvent="EditGridPanelStudyProtocolsCell" />
</AjaxEvents>
</ext:GridPanel>
</ext:LayoutRow>
<ext:LayoutRow RowHeight="0.45">
<ext:Panel ID="Panel4" runat="server" Title="Consents" />
</ext:LayoutRow>
</ext:RowLayout>
<ext:Store ID="storeStudyProtocols" runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="SampleTypeCategoryID" Type="Int" />
<ext:RecordField Name="ProtocolTypeID" Type="Int" />
<ext:RecordField Name="MinOccurance" Type="Int" />
<ext:RecordField Name="MaxOccurance" Type="Int" />
<ext:RecordField Name="OccuranceTypeID" Type="Int" />
<ext:RecordField Name="OccuranceStart" Type="Int" />
<ext:RecordField Name="OccuranceStartTypeID" Type="Int" />
<ext:RecordField Name="StudyID" Type="Int" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Body>
</ext:Tab>
Main page Code behind
[AjaxMethod]
protected void AddStudyProtocol(Object sender, AjaxEventArgs e)
{
UCAddEditStudyProtocol.ShowForm = true;
UCAddEditStudyProtocol.WindowAddEditStudyProtocol.Show();
}