[CLOSED] Razor/MVC custom search

Page 2 of 2 FirstFirst 12
  1. #11
    The controller code calls a WCF service and returns a StoreResult. The code is as follows:

    public StoreResult GetOrganisations()
            {
                StoreResult response = new StoreResult();
                string filter = HttpContext.Request["query"];
    
                int totalCount = 0;
                PartyManagerServiceClient pmService = new PartyManagerServiceClient();
    
                List<OrganisationVO> organisations = (List<OrganisationVO>)MemoryCache.Default["OrganisationVOs"];
    
                List<Organisation> orgs = new List<Organisation>();
                if (organisations == null)
                {
                    organisations = new List<OrganisationVO>();
                    orgs = pmService.GetOrganisationsByName("", 0, 4000, ref totalCount);
                    foreach (Organisation org in orgs)
                    {
                        OrganisationVO orgVO = new OrganisationVO();
                        orgVO = Mapper.ToViewObject(org);
                        organisations.Add(orgVO);
                    }
    
                    MemoryCache.Default.AddOrGetExisting("OrganisationVOs", organisations, DateTime.Now.AddMinutes(10));
                }
    
                List<OrganisationVO> data = new List<OrganisationVO>();
                data = organisations.ToList();
    
                if (!string.IsNullOrEmpty(filter) && filter != "*")
                {
                    data.RemoveAll(filterOrg => !filterOrg.DisplayName.ToLower().StartsWith(filter.ToLower()));
                }
    
                response.Data = data;
                response.Total = data.Count;
                return response;
    
            }
    OrganisationVO:

    public class OrganisationVO
        {
            public int PartyID { get; set; }
            public string OrganisationCode { get; set; }
            public List<string> OrganisationNames { get; set; }
            public string DisplayName { get; set; }
            public bool IsCustomer { get; set; }
            public bool IsSupplier { get; set; }
    
            public OrganisationVO()
            {
                OrganisationNames = new List<string>();
            }
        }
    
        public class OrganisationVOCollection : List<OrganisationVO>
        {}
    The other stuff is defined in the contracts/proxies from the WCF service. As I said this stuff works perfectly with the previous beta build - it's just the update I did this morning that seems to have broken it...
  2. #12
    Ok, thanks.

    What is a response? It should help us to reproduce the problem.
  3. #13
    The response is basically list of OrganisationVO's as defined above. Examples:

    DisplayName "1-Stop Connections" string
    IsCustomer false bool
    IsSupplier false bool
    OrganisationCode "1SC" string
    PartyID 23871 int


    DisplayName "AAPT" string
    IsCustomer false bool
    IsSupplier false bool
    OrganisationCode "APT" string
    PartyID 20880 int

    there is also a OrganisationNames collection but it's irrelevant to this I think - it's basically a list of organisation name objects but they are not used to bind to the combobox.
  4. #14
    Does setting up
    .AutoLoad(false)
    for the Store solve the problem?
  5. #15
    thanks Daniil! .Autoload(false) fixed the problem.
  6. #16
    Good. Though, at the first glance there is a bug.

    I was able to reproduce the problem with a simple example below.

    Just type something into the ComboBox - a JS error will occur.

    Setting AutoLoad="false" solves the problem, but I think this is a work-around, not a fix.

    We are investigating further.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Store_ReadData(object sender, StoreRefreshDataEventArgs e)
        {
            Store store = sender as Store;
            store.DataSource = new object[] 
                { 
                    new object[] { "1", "item1" },
                    new object[] { "2", "item2" },
                    new object[] { "3", "item3" }
                };
            store.DataBind();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:ComboBox 
                runat="server" 
                MinChars="1" 
                PageSize="1"
                Width="300">
                <Store>
                    <ext:Store 
                        runat="server" 
                        OnReadData="Store_ReadData" 
                        AutoLoad="true">
                        <Proxy>
                            <ext:PageProxy>
                                <Reader>
                                    <ext:ArrayReader />
                                </Reader>
                            </ext:PageProxy>
                        </Proxy>
                        <Model>
                            <ext:Model runat="server">
                                <Fields>
                                    <ext:ModelField Name="value" />
                                    <ext:ModelField Name="text" />
                                </Fields>
                            </ext:Model>
                        </Model>                
                    </ext:Store>
                </Store>
            </ext:ComboBox>
        </form>
    </body>
    </html>
  7. #17
    This bug comes from ExtJS. We decided to wait its next release.
  8. #18
    The bug with
    AutoLoad="true"
    is gone.

    Here is the related thread on Sencha forums:
    http://www.sencha.com/forum/showthread.php?191149
Page 2 of 2 FirstFirst 12

Similar Threads

  1. [CLOSED] [1.0] Custom search help
    By edigital in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Apr 10, 2015, 7:44 PM
  2. [CLOSED] Custom Search Combobox
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 04, 2010, 7:29 PM
  3. [CLOSED] [1.0] custom search
    By vali1993 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 23, 2010, 3:48 PM
  4. [CLOSED] custom search v1.0 IE6
    By sharif in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 18, 2010, 7:05 PM
  5. Custom Search
    By sharif in forum 1.x Help
    Replies: 0
    Last Post: Jul 14, 2009, 4:04 PM

Posting Permissions