[CLOSED] Populating a Store in ascx

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Populating a Store in ascx

    What am I doing incorrectly. I have moved a dialog out of my aspx and into its own ascx. But when the data attempts to populate the store can not be found.

    Default.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html >
    <html>
    <head runat="server">
        <title>Dialog Test</title>
        <script type="text/javascript">
            function beforeCreate() {
                var dialog = Ext.getCmp("Dialog01a");
                if (dialog) {
                    dialog.show();
                    return false;
                }
    
                return true;
            }
        </script>
        <script runat="server">
            protected void CreateChooser(object sender, DirectEventArgs e)
            {
                UserControlRenderer.Render(new UserControlRendererConfig 
                         { UserControlPath = "Dialog01.ascx", SingleControl = true });
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button runat="server" Icon="Add" Text="Dialog #01">
            <DirectEvents>
                <Click OnEvent="CreateChooser" Before="return beforeCreate();" />
            </DirectEvents>
        </ext:Button>
        <div id="images" style="margin: 20px; width: 600px;">
        </div>
        </form>
    </body>
    </html>
    Dialog01.ascx (Removed buttons to reduce code)
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server" >
    
        protected void Members_LoadData(object sender, StoreReadDataEventArgs e)
        {
            List<object> data = new List<object>();
    
            data.Add(new object[] { 4567, "Smith, Bob" });
            data.Add(new object[] { 3332, "Jones, Jimmy" });
    
            Members_Store.DataSource = data;
            Members_Store.DataBind();
        }
    
    </script>
    <ext:Window ID="Dialog01a" runat="server" ClientIDMode="Static" Title="Members"
        Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False">
        <Items>
            <ext:FormPanel runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;">
                <Items>
                    <ext:DisplayField runat="server" Text="Select a member." />
                    <ext:Container runat="server">
                        <Content>
                            <hr />
                        </Content>
                    </ext:Container>
                    <ext:MultiSelect ID="RequestAssignAO" runat="server" ClientIDMode="Static" SingleSelect="true"
                        Height="180" DisplayField="DisplayNm" ValueField="UserId" AllowBlank="false"
                        MsgTarget="None">
                        <ListConfig runat="server" LoadingText="Retrieving Action Officers ..." />
                        <Store>
                            <ext:Store ID="Members_Store" runat="server" ClientIDMode="Static" 
                                           OnReadData="Members_LoadData">
                                <Proxy>
                                    <ext:PageProxy>
                                        <Reader>
                                            <ext:ArrayReader />
                                        </Reader>
                                    </ext:PageProxy>
                                </Proxy>
                                <Model>
                                    <ext:Model runat="server" IDProperty="UserId">
                                        <Fields>
                                            <ext:ModelField Name="UserId" Type="Int" />
                                            <ext:ModelField Name="DisplayNm" Type="String" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:MultiSelect>
                </Items>
            </ext:FormPanel>
        </Items>
    </ext:Window>
    Last edited by Daniil; Sep 17, 2013 at 6:25 AM. Reason: [CLOSED]
  2. #2
    You did not recreate dynamic control (any dynamic control must be recreated to handle own events)
    Store from user control makes ajax request to get data but on the server side the instance is not found because you create user control only once (in button click handler)

    In your case, it is better to use http handler to get data, otherwise UserControlRenderer is not an option for you (if you want to use PageProxy then need to add user control to the page every request)
    Vladimir Shcheglov
    Sr. Developer
  3. #3
    Got it. I have avoided going into HTTP handlers because it hurts my head everytime I begin to look at it. I will attempt something this weekend and post my success or ask for additional help.
  4. #4
    HTTP handlers is a good feature to have in your skill arsenal. Here is an example for references:
    https://examples2.ext.net/#/GridPane...rting/Handler/
  5. #5
    I attempted to implement based on the following example but still received the same error:

    https://examples2.ext.net/#/Loaders/.../Http_Handler/

    I guess I should look at:

    https://examples2.ext.net/#/Loaders/Data/Overview/
  6. #6
    Please clarify are you still using a PageProxy?
  7. #7
    Quote Originally Posted by cwolcott View Post
    I attempted to implement based on the following example but still received the same error:

    https://examples2.ext.net/#/Loaders/.../Http_Handler/

    I guess I should look at:

    https://examples2.ext.net/#/Loaders/Data/Overview/
    Did you find a solution for this thread?
  8. #8
    Hi @posser,

    If you provide us with a test case to reproduce, we could investigate it.
  9. #9
    Posser,

    I was able to develop what I needed. Who knows if it will satisfy your needs. Basically it was trying to understand a new technique. Even though I have been coding for 25+ years I still like to slowly build things up so that I can fully understand the process. Below are my code examples that I worked through step by step.

    There are four examples listed below. Each examples builds toward the final solution.

    • Attempt01 - Everything in one aspx file.
      Files - AO.aspx
    • Attempt02 - Break out the data handling into an ashx file.
      Files - AO.aspx, Ao2Handler.ashx, Ao2Handler.ashx.cs
    • Attempt03 - Break out the control into an ascx file.
      Files - AO.aspx, AO.ascx, Ao3Handler.ashx, Ao3Handler.ashx.cs
    • Attempt04 - Change the hard coded data in ashx to LINQ.
      Files - AO.aspx, AO.ascx, Ao4Handler.ashx, Ao4Handler.ashx.cs, LINQ files not included


    Good luck and let me know how things work out for you.




    Directory - Attempt01 : File - AO.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void AssignAoClick(object sender, DirectEventArgs e)
        {
            int newAoId = Convert.ToInt32(e.ExtraParams["UserId"]);
            string newAoName = e.ExtraParams["DisplayNm"];
            dfActionOfficer.Text = "[" + newAoId.ToString() + "] " + newAoName;
        }
    
        protected void JdsMembers_LoadData(object sender, StoreReadDataEventArgs e)
        {
    
            List<object> data = new List<object>()
                {
                    new {UserId = 1, DisplayNm = "Jones, Jimmy A."},
                    new {UserId = 2, DisplayNm = "Shere, Christy"},
                    new {UserId = 3, DisplayNm = "Smith, Bob"},
                    new {UserId = 4, DisplayNm = "Taylor, Anthony"},
                    new {UserId = 5, DisplayNm = "Wilson, Lisa"}
                };
    
            JdsMembers_Store.DataSource = data;
            JdsMembers_Store.DataBind();
        }
    
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Popup Dialog</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Button runat="server" Text="Assign Action Officer" Icon="UserAdd" Handler="#{ActionOfficerWindow}.show()" />
        <ext:DisplayField ID="dfActionOfficer" runat="server" ClientIDMode="Static" FieldLabel="Action Officer" Text="n/a" />
        <ext:Window ID="ActionOfficerWindow" runat="server" ClientIDMode="Static" Title="Action Officers"
            Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False" Hidden="true"
            DefaultRenderTo="Body" CloseAction="Hide">
            <Items>
                <ext:FormPanel runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;"
                    Cls="reopenPanel">
                    <Items>
                        <ext:DisplayField runat="server" Text="[1] Select an action officer to be assigned to this request." />
                        <ext:Container runat="server">
                            <Content>
                                <hr />
                            </Content>
                        </ext:Container>
                        <ext:MultiSelect ID="RequestAssignAO" runat="server" ClientIDMode="Static" SingleSelect="true"
                            Height="180" DisplayField="DisplayNm" ValueField="UserId" AllowBlank="false"
                            MsgTarget="None">
                            <ListConfig runat="server" LoadingText="Retrieving Action Officers ..." />
                            <Store>
                                <ext:Store ID="JdsMembers_Store" runat="server" ClientIDMode="Static" OnReadData="JdsMembers_LoadData">
                                    <Proxy>
                                        <ext:PageProxy />
                                    </Proxy>
                                    <Model>
                                        <ext:Model runat="server" IDProperty="UserId">
                                            <Fields>
                                                <ext:ModelField Name="UserId" Type="Int" />
                                                <ext:ModelField Name="DisplayNm" Type="String" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                        </ext:MultiSelect>
                    </Items>
                    <Listeners>
                        <ValidityChange Handler="#{AssignAoDlgBtn}.setDisabled(!valid);" />
                    </Listeners>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="AssignAoDlgBtn" runat="server" Text="Assign" Icon="UserGreen" FormBind="true"
                    Disabled="true" Handler="App.ActionOfficerWindow.close();">
                    <DirectEvents>
                        <Click OnEvent="AssignAoClick">
                            <ExtraParams>
                                <ext:Parameter Name="UserId" Value="#{RequestAssignAO}.getSelected()[0].data['UserId']"
                                    Mode="Raw" />
                                <ext:Parameter Name="DisplayNm" Value="#{RequestAssignAO}.getSelected()[0].data['DisplayNm']"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button runat="server" Text="Refresh" Icon="Reload" Handler="App.RequestAssignAO.store.reload();  App.RequestAssignAO.clearValue();" />
                <ext:Button runat="server" Text="Cancel" Icon="Cancel" Handler="App.ActionOfficerWindow.close();" />
            </Buttons>
            <Listeners>
                <Show Handler="if (App.RequestAssignAO.getStore().count() == 0) App.RequestAssignAO.getStore().reload(); App.RequestAssignAO.clearValue();" />
            </Listeners>
        </ext:Window>
    </body>
    </html>



    Directory - Attempt02 : File - AO.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void AssignAoClick(object sender, DirectEventArgs e)
        {
            int newAoId = Convert.ToInt32(e.ExtraParams["UserId"]);
            string newAoName = e.ExtraParams["DisplayNm"];
            dfActionOfficer.Text = "[" + newAoId.ToString() + "] " + newAoName;
        }    
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Popup Dialog with Data Handler</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        <ext:Button runat="server" Text="Assign Action Officer" Icon="UserAdd" Handler="#{ActionOfficerWindow}.show()" />
        <ext:DisplayField ID="dfActionOfficer" runat="server" ClientIDMode="Static" FieldLabel="Action Officer" Text="n/a" />
        <ext:Window ID="ActionOfficerWindow" runat="server" ClientIDMode="Static" Title="Action Officers"
            Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False" Hidden="true"
            DefaultRenderTo="Body" CloseAction="Hide">
            <Items>
                <ext:FormPanel runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;"
                    Cls="reopenPanel">
                    <Items>
                        <ext:DisplayField runat="server" Text="Select an action officer to be assigned to this request." />
                        <ext:Container runat="server">
                            <Content>
                                <hr />
                            </Content>
                        </ext:Container>
                        <ext:MultiSelect ID="RequestAssignAO" runat="server" ClientIDMode="Static" SingleSelect="true"
                            Height="180" DisplayField="DisplayNm" ValueField="UserId" AllowBlank="false"
                            MsgTarget="None">
                            <ListConfig runat="server" LoadingText="Retrieving Action Officers ..." />
                            <Store>
                                <ext:Store ID="JdsMembers_Store" runat="server" ClientIDMode="Static">
                                    <Proxy>
                                        <ext:AjaxProxy Url="Ao2Handler.ashx" />
                                    </Proxy>
                                    <Model>
                                        <ext:Model runat="server" IDProperty="UserId">
                                            <Fields>
                                                <ext:ModelField Name="UserId" Type="Int" />
                                                <ext:ModelField Name="DisplayNm" Type="String" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                        </ext:MultiSelect>
                    </Items>
                    <Listeners>
                        <ValidityChange Handler="#{AssignAoDlgBtn}.setDisabled(!valid);" />
                    </Listeners>
                </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="AssignAoDlgBtn" runat="server" Text="Assign" Icon="UserGreen" FormBind="true"
                    Disabled="true" Handler="App.ActionOfficerWindow.close();">
                    <DirectEvents>
                        <Click OnEvent="AssignAoClick">
                            <ExtraParams>
                                <ext:Parameter Name="UserId" Value="#{RequestAssignAO}.getSelected()[0].data['UserId']"
                                    Mode="Raw" />
                                <ext:Parameter Name="DisplayNm" Value="#{RequestAssignAO}.getSelected()[0].data['DisplayNm']"
                                    Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
                <ext:Button runat="server" Text="Refresh" Icon="Reload" Handler="App.RequestAssignAO.store.reload(); App.RequestAssignAO.clearValue();" />
                <ext:Button runat="server" Text="Cancel" Icon="Cancel" Handler="App.ActionOfficerWindow.close();" />
            </Buttons>
            <Listeners>
                <Show Handler="if (App.RequestAssignAO.getStore().count() == 0) App.RequestAssignAO.getStore().reload(); App.RequestAssignAO.clearValue();" />
            </Listeners>
        </ext:Window>
    </body>
    </html>
    Directory - Attempt02 : File - Ao2Handler.ashx
    <%@ WebHandler Language="C#" CodeBehind="Ao2Handler.ashx.cs" Class="Ao2Handler" %>
    Directory - Attempt02 : File - Ao2Handler.ashx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    using Ext.Net;
    
        /// <summary>
        /// Summary description for AOHandler
        /// </summary>
        public class Ao2Handler : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/javascript";
    
                List<object> data = new List<object>()
                {
                    new {UserId = 1, DisplayNm = "Jones, Jimmy"},
                    new {UserId = 2, DisplayNm = "Shere, Christy B."},
                    new {UserId = 3, DisplayNm = "Smith, Bob"},
                    new {UserId = 4, DisplayNm = "Taylor, Anthony"},
                    new {UserId = 5, DisplayNm = "Wilson, Lisa"}
                };
    
                MetaConfig metaData = MetaConfig.From(data);
                metaData.IDProperty = "UserId";
                metaData.Root = "data";
    
                new StoreResponseData
                {
                    Data = JSON.Serialize(data),
                    MetaData = metaData
                }.Return();
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }



    Directory - Attempt03 : File - AO.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void CreateAoDialog(object sender, DirectEventArgs e)
        {
            UserControlRenderer.Render(
                new UserControlRendererConfig { UserControlPath = "AO.ascx", SingleControl = true });
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>ASCX Dialog w/ Handler</title>
    </head>
    <body>
        <script type="text/javascript">
            function beforeCreateAoDialog() {
    
                var dialog = Ext.getCmp("ActionOfficerWindow");
                if (dialog) {
                    dialog.show();
                    return false;
                };
    
                return true;
            }
        </script>
        <ext:ResourceManager runat="server" />
        <ext:Button runat="server" Text="Assign Action Officer" Icon="UserAdd">
            <DirectEvents>
                <Click OnEvent="CreateAoDialog" Before="return beforeCreateAoDialog();" />
            </DirectEvents>
        </ext:Button>
        <ext:DisplayField ID="dfActionOfficer" runat="server" ClientIDMode="Static" FieldLabel="Action Officer"
            Text="n/a">
            <MessageBusListeners>
                <ext:MessageBusListener Name="AoDialog.*" Handler="#{dfActionOfficer}.setValue(data[1]);" />
            </MessageBusListeners>
        </ext:DisplayField>
    </body>
    </html>
    Directory - Attempt03 : File - AO.ascx
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Window ID="ActionOfficerWindow" runat="server" Title="Action Officers"
        Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False"
        DefaultRenderTo="Body" CloseAction="Hide">
        <HtmlBin>
            <script type="text/javascript">
                function closeAoDialog() {
                    App.ActionOfficerWindow.close();
                }
    
                function publishAoAssignment() {
    
                    var data1 = new Array();
                    data1[0] = App.RequestAssignAO.getSelected()[0].data['UserId'];
                    data1[1] = App.RequestAssignAO.getSelected()[0].data['DisplayNm'];
                    Ext.net.Bus.publish('AoDialog.Assign', data1);
    
                    closeAoDialog();
                }
    
                function refreshAoList() {
    
                    App.RequestAssignAO.store.reload();
                    App.RequestAssignAO.clearValue();
                }
    
            </script>
        </HtmlBin>
        <Items>
            <ext:FormPanel runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;"
                Cls="reopenPanel">
                <Items>
                    <ext:DisplayField runat="server" Text="Select an action officer to be assigned to this request." />
                    <ext:Container runat="server">
                        <Content>
                            <hr />
                        </Content>
                    </ext:Container>
                    <ext:MultiSelect ID="RequestAssignAO" runat="server" SingleSelect="true"
                        Height="180" DisplayField="DisplayNm" ValueField="UserId" AllowBlank="false"
                        MsgTarget="None">
                        <ListConfig runat="server" LoadingText="Retrieving Action Officers ..." />
                        <Store>
                            <ext:Store runat="server">
                                <Proxy>
                                    <ext:AjaxProxy Url="Ao3Handler.ashx" />
                                </Proxy>
                                <Model>
                                    <ext:Model runat="server" IDProperty="UserId">
                                        <Fields>
                                            <ext:ModelField Name="UserId" Type="Int" />
                                            <ext:ModelField Name="DisplayNm" Type="String" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:MultiSelect>
                </Items>
                <Listeners>
                    <ValidityChange Handler="#{AssignAoDlgBtn}.setDisabled(!valid);" />
                </Listeners>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button ID="AssignAoDlgBtn" runat="server" Text="Assign" Icon="UserGreen" FormBind="true"
                Disabled="true" OnClientClick="publishAoAssignment" />
            <ext:Button runat="server" Text="Refresh" Icon="Reload" OnClientClick="refreshAoList" />
            <ext:Button runat="server" Text="Cancel" Icon="Cancel" OnClientClick="closeAoDialog" />
        </Buttons>
    </ext:Window>
    Directory - Attempt03 : File - Ao3Handler.ashx
    <%@ WebHandler Language="C#" CodeBehind="Ao3Handler.ashx.cs" Class="Ao3Handler" %>
    Directory - Attempt03 : File - Ao3Handler.ashx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    using Ext.Net;
    
        /// <summary>
        /// Summary description for AOHandler
        /// </summary>
        public class Ao3Handler : IHttpHandler
        {
              
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/javascript";
    
                List<object> data = new List<object>()
                {
                    new {UserId = 1, DisplayNm = "Jones, Jimmy"},
                    new {UserId = 2, DisplayNm = "Shere, Christy"},
                    new {UserId = 3, DisplayNm = "Smith, Bob C."},
                    new {UserId = 4, DisplayNm = "Taylor, Anthony"},
                    new {UserId = 5, DisplayNm = "Wilson, Lisa"}
                };
    
                MetaConfig metaData = MetaConfig.From(data);
                metaData.IDProperty = "UserId";
                metaData.Root = "data";
    
                new StoreResponseData
                {
                    Data = JSON.Serialize(data),
                    MetaData = metaData
                }.Return();
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }



    Directory - Attempt04 : File - AO.aspx
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void CreateAoDialog(object sender, DirectEventArgs e)
        {
            UserControlRenderer.Render(
                new UserControlRendererConfig { UserControlPath = "AO.ascx", SingleControl = true });
        }
        
        [DirectMethod]
        public static void AssignAo (int newAoId, string newAoNm) {
            X.MessageBox.Notify("AssignAo ...", "[" + newAoId.ToString() + "] " + newAoNm).Show();
    
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>ASCX Dialog w/ Handler to DB</title>
    </head>
    <body>
        <script type="text/javascript">
            function beforeCreateAoDialog() {
    
                var dialog = Ext.getCmp("ActionOfficerWindow");
                if (dialog) {
                    dialog.show();
                    return false;
                };
    
                return true;
            }
        </script>
        <ext:ResourceManager runat="server" />
        <ext:Button runat="server" Text="Assign Action Officer" Icon="UserAdd">
            <DirectEvents>
                <Click OnEvent="CreateAoDialog" Before="return beforeCreateAoDialog();" />
            </DirectEvents>
        </ext:Button>
        <ext:DisplayField ID="dfActionOfficer" runat="server" ClientIDMode="Static" FieldLabel="Action Officer"
            Text="n/a">
            <MessageBusListeners>
                <ext:MessageBusListener Name="AoDialog.*" Handler="#{dfActionOfficer}.setValue(data[1]); App.direct.AssignAo(data[0],data[1]);" />
            </MessageBusListeners>
        </ext:DisplayField>
    </body>
    </html>
    Directory - Attempt04 : File - AO.ascx
    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Window ID="ActionOfficerWindow" runat="server" Title="Action Officers"
        Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False"
        DefaultRenderTo="Body" CloseAction="Hide">
        <HtmlBin>
            <script type="text/javascript">
                function closeAoDialog() {
                    App.ActionOfficerWindow.close();
                }
    
                function publishAoAssignment() {
    
                    var data1 = new Array();
                    data1[0] = App.RequestAssignAO.getSelected()[0].data['UserId'];
                    data1[1] = App.RequestAssignAO.getSelected()[0].data['DisplayNm'];
                    Ext.net.Bus.publish('AoDialog.Assign', data1);
    
                    closeAoDialog();
                }
    
                function refreshAoList() {
    
                    App.RequestAssignAO.store.reload();
                    App.RequestAssignAO.clearValue();
                }
    
            </script>
        </HtmlBin>
        <Items>
            <ext:FormPanel runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;"
                Cls="reopenPanel">
                <Items>
                    <ext:DisplayField runat="server" Text="Select an action officer to be assigned to this request." />
                    <ext:Container runat="server">
                        <Content>
                            <hr />
                        </Content>
                    </ext:Container>
                    <ext:MultiSelect ID="RequestAssignAO" runat="server" SingleSelect="true"
                        Height="180" DisplayField="DisplayNm" ValueField="UserId" AllowBlank="false"
                        MsgTarget="None">
                        <ListConfig runat="server" LoadingText="Retrieving Action Officers ..." />
                        <Store>
                            <ext:Store runat="server">
                                <Proxy>
                                    <ext:AjaxProxy Url="Ao4Handler.ashx" />
                                </Proxy>
                                <Model>
                                    <ext:Model runat="server" IDProperty="UserId">
                                        <Fields>
                                            <ext:ModelField Name="UserId" Type="Int" />
                                            <ext:ModelField Name="DisplayNm" Type="String" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:MultiSelect>
                </Items>
                <Listeners>
                    <ValidityChange Handler="#{AssignAoDlgBtn}.setDisabled(!valid);" />
                </Listeners>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button ID="AssignAoDlgBtn" runat="server" Text="Assign" Icon="UserGreen" FormBind="true"
                Disabled="true" OnClientClick="publishAoAssignment" />
            <ext:Button runat="server" Text="Refresh" Icon="Reload" OnClientClick="refreshAoList" />
            <ext:Button runat="server" Text="Cancel" Icon="Cancel" OnClientClick="closeAoDialog" />
        </Buttons>
    </ext:Window>
    Directory - Attempt04 : File - Ao4Handler.ashx
    <%@ WebHandler Language="C#" CodeBehind="Ao4Handler.ashx.cs" Class="Ao4Handler" %>
    Directory - Attempt04 : File - Ao4Handler.ashx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    using Ext.Net;
    
    
        /// <summary> 
        /// Summary description for AOHandler
        /// </summary>
        public class Ao4Handler : IHttpHandler
        {
             
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/javascript";
    
                JdsWebDataContext db = new JdsWebDataContext();
                var jdsMembers = db.RegUser_JdsRoles
                    .Where(r => r.RoleID == 0 && r.RegisteredUser.IsActive == true)
                    .OrderBy(r => r.RegisteredUser.LastNm)
                    .ThenByDescending(r => r.RegisteredUser.FirstNm);
    
                List<object> data = new List<object>();
    
                foreach (RegUser_JdsRole user in jdsMembers)
                {
                    data.Add(new { UserId = user.RegisteredUser.UserID, 
                                   DisplayNm = user.RegisteredUser.FormatNm("L,ftmgs") });
                }
    
                MetaConfig metaData = MetaConfig.From(data);
                metaData.IDProperty = "UserId";
                metaData.Root = "data";
    
                new StoreResponseData
                {
                    Data = JSON.Serialize(data),
                    MetaData = metaData
                }.Return();
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    LINQ Class not shown ...
  10. #10
    Hello cwolcott

    Thank you very much for your code samples, they were very helpful.
    I resolved my issue using your third attempt, and now everything is doing great.

    I was trying to populate my combobox in a dynamic user control, but it was not being found due to postback issues (i was using ArrayReader in a PageProxy). But with AjaxProxy handling data by jason my store is now working as expected.

    Bellow is my solution, I'm posting here to help other users like you just did.

    Once again Thank you cwolcott.

    ASPX (parent page):

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void CreateAoDialog(object sender, DirectEventArgs e)
        {
            UserControlRenderer.Render(
                new UserControlRendererConfig { UserControlPath = "AO.ascx", SingleControl = true });        
        }
    </script>
    <!DOCTYPE html>
    <html>
    <head id="Head1" runat="server">
        <title>ASCX Dialog w/ Handler</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Button ID="Button1" runat="server" Text="Assign Action Officer" Icon="UserAdd">
            <DirectEvents>
                <Click OnEvent="CreateAoDialog" />
            </DirectEvents>
        </ext:Button>    
    </body>
    </html>
    ASCX (uc form page):

    <%@ Control Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:Window ID="ActionOfficerWindow" runat="server" Title="Action Officers"
        Width="270" Layout="FitLayout" Resizable="false" Modal="true" Border="False"
        DefaultRenderTo="Body" CloseAction="Hide">
        <Items>
            <ext:FormPanel ID="FormPanel1" runat="server" BodyPadding="10" BodyStyle="background:transparent; padding:5px 10px 10px;"
                Cls="reopenPanel">
                <Items>
                    <ext:TextField ID="TextField1" runat="server" FieldLabel="Parameter" EmptyText="Untitled Domain" />
                    <ext:ComboBox ID="RequestAssignAO" runat="server" AllowBlank="false" MsgTarget="None">
                        <Store>
                            <ext:Store runat="server" AutoLoad="false">
                                <Parameters>
                                    <ext:StoreParameter Name="paramName" Value="#{TextField1}.getValue()" Mode="Raw" />
                                </Parameters>
                                <Proxy>
                                    <ext:AjaxProxy Url="Ao3Handler.ashx" />
                                </Proxy>
                                <Model>
                                    <ext:Model runat="server" IDProperty="UserId">
                                        <Fields>
                                            <ext:ModelField Name="text" Type="String" />
                                        </Fields>
                                    </ext:Model>
                                </Model>
                            </ext:Store>
                        </Store>
                    </ext:ComboBox>
                </Items>
            </ext:FormPanel>
        </Items>
    </ext:Window>
    ASHX (data handler):

    public class Ao3Handler : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/javascript";
    
                List<object> data = new List<object>();
    
                data.Add(new { text = DateTime.Now.ToString() });
                data.Add(new { text = context.Request["paramName"] });
                data.Add(new {text = "item3"});
    
                MetaConfig metaData = MetaConfig.From(data);
                metaData.Root= "data";
                
    
                new StoreResponseData
                {
                    Data = JSON.Serialize(data),
                    MetaData = metaData
                }.Return();
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] ComboBox Not Populating on First Store Reload
    By elisa in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 02, 2013, 5:17 PM
  2. Replies: 17
    Last Post: Apr 22, 2013, 8:44 PM
  3. Replies: 6
    Last Post: Oct 22, 2012, 1:51 PM
  4. Populating ComboBox from Store on page load
    By ikhwanhayat in forum 1.x Help
    Replies: 7
    Last Post: Feb 06, 2012, 4:56 PM
  5. Replies: 5
    Last Post: Jan 04, 2011, 9:09 PM

Posting Permissions