Refresh Grid Panel when Window User Control is hidden

  1. #1

    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
    
    <%@ 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" 
                Show&#111;nload="false" 
                Width="350"
                Height="350"
                BodyStyle="padding:15px;"
                Resizable="false"
                Draggable="true"
                Modal="true"
                Center&#111;nload="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();
    
        }
  2. #2

    RE: Refresh Grid Panel when Window User Control is hidden

    Hi,

    Try to use the OnRefreshData event of the Store to reload the current page in the grid.

    hope the following example may solve your issue.

    https://examples1.ext.net/Examples/G...Window_Remote/


    Thanks

Similar Threads

  1. Window and User Control
    By gpcontreras in forum 1.x Help
    Replies: 3
    Last Post: Mar 30, 2012, 11:47 PM
  2. Replies: 2
    Last Post: Feb 06, 2012, 9:06 AM
  3. [CLOSED] Maximize error on Modal Window in User Control
    By jwf in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 13, 2011, 4:24 PM
  4. Show Modal window from a User Control
    By yourspraba in forum 1.x Help
    Replies: 1
    Last Post: Jun 29, 2010, 5:43 PM
  5. [CLOSED] Panel / Window Title gets hidden in lesser working space.
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 08, 2008, 9:25 AM

Posting Permissions