[CLOSED] Store loads twice

  1. #1

    [CLOSED] Store loads twice

    Hi,

    I can't understand why the store loads again when I select an item in the list. What's the use of that?
    I put a breakpoint on the GetData() function of the web service and it is called on load of the page and on select of the item.

    In my real scenario I have several cascading lists and a quite time consuming data query so this behavior is very bad for me.
    Can you help me, please?
    Thanks in advance
    Marco


    Test.aspx
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager runat="server" />
                        <ext:ComboBox ID="cbFamiglieProdotto" runat="server"  ForceSelection="true"  DisplayField="Description" ValueField="Code" Flex="1"
                            EmptyText="Seleziona un prodotto..."  SelectOnFocus="true"  Margins="0 8 0 0" TypeAhead="true">
                                   <Store>
                <ext:Store ID="stFamiglieProdotto" runat="server" PageSize="10">
                    <Proxy>
                        <ext:AjaxProxy Json="true" Url="DataService.asmx/GetData">
                            <ActionMethods Read="POST" />                            
                            <Reader>
                                <ext:JsonReader Root="d.Data" TotalProperty="d.Total" />
                            </Reader>
                        </ext:AjaxProxy>
                    </Proxy>
                    <Model>
                        <ext:Model runat="server">
                            <Fields>
                                <ext:ModelField Name="Code" />
                                <ext:ModelField Name="Description" />
                            </Fields>
                        </ext:Model>
                    </Model>
    
                </ext:Store>            
            </Store>               
                            <Listeners>
                    </Listeners>                
                        </ext:ComboBox>  
    
        </form>
    </body>
    </html>
    DataService.asmx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    
    namespace Ext.Net.Examples.Examples.Loaders.Data.Overview
    {
        /// <summary>
        /// Сводное описание для DataService
        /// </summary>
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // Чтобы разрешить вызывать веб-службу из скрипта с помощью ASP.NET AJAX, раскомментируйте следующую строку. 
        [System.Web.Script.Services.ScriptService]
        public class DataService : System.Web.Services.WebService
        {
            [WebMethod]
            public StoreResponseData GetData()
            {
                List<object> recordList = new List<object>()
                {
                    new {Code = "First 1", Description = "Last 1"},
                    new {Code = "First 2", Description = "Last 2"},
                    new {Code = "First 3", Description = "Last 3"},
                    new {Code = "First 4", Description = "Last 4"},
                    new {Code = "First 5", Description = "Last 5"}
                };
    
                StoreResponseData storeResponse = new StoreResponseData();
                storeResponse.Data = JSON.Serialize(recordList);
                storeResponse.Total = recordList.Count;
                return storeResponse;
    
            }
        }
    }
    Last edited by Daniil; Jul 20, 2012 at 2:56 PM. Reason: [CLOSED]
  2. #2
    Hi,

    1. The first time the Store loads its data due to its default
    AutoLoad="true"
    You can set up
    AutoLoad="false"
    to avoid this request.

    2. The second time the ComboBox initiates a load request due to its default:
    QueryMode="Remote"
    .

    If you set up
    QueryMode="Local"
    the ComboBox should use already loaded data.

    Personally, I would set up
    AutoLoad="false"
    to avoid an initial load request. It is a good practice, I think.
  3. #3
    Thank you veri much Daniil, it works.

    I agree with you it is a good practice, in general but I save some time starting to execute the query on page load because it takes long.
    Othewise the query would start when the user opens the combo.

    In the same example I wolud like to show the "loading..." image during the store load. How can I achieve that?

    Marco
  4. #4
    Quote Originally Posted by marco.morreale View Post
    In the same example I wolud like to show the "loading..." image during the store load. How can I achieve that?
    For initial page load request? Or when a user clicks a ComboBox trigger? Or both?

    Also where do you need to show a mask?
  5. #5
    For initial page request and when the store.load() function is called from javascript.

    The best would be to show the mask on the combo bound to the store but the center of the screen would be ok, also.

    M
  6. #6
    Please set up BeforeLoad and Load listeners for the Store to, respectively, mask and unmask.

    Well, a ComboBox is too small for a mask box, I think, but you can try:
    Ext.net.Mask.show({
        el : App.ComboBox1.el
    })
    If you won't like how it looks, when just
    Ext.net.Mask.show();
    To unmask please use:
    Ext.net.Mask.hide();
  7. #7
    I tried:

    Ext.net.Mask.show({el : App.cbFamiglieProdotto.el});
    but I got the error: Run-time error of Microsoft JScript: 'App.ComboBox1.el' is null or not an object (translated from Italian...)

    maybe I am missing something. Should I add some properties to the combo?

    M
  8. #8
    I replaced

    App.cbFamiglieProdotto.el

    with

    App.DynamicContent_Ordine1_cbFamiglieProdotto.el

    and now I get a different error. Please, see attachment.

    Click image for larger version. 

Name:	error.png 
Views:	142 
Size:	30.6 KB 
ID:	4517
  9. #9
    I guess a ComboBox is not rendered yet on the first BeforeLoad triggering.

    Please try to set up
    Delay="10"
    for the BeforeLoad listener.
  10. #10
    I get the same error even with Delay="50" but I think I'll reverto to the other solution.
    I prefer the mask at the center of the screen.
    You can mark as closed.
    Thank you very much.
    M

Similar Threads

  1. GridPanel auto-loads when I manually add a row to it
    By mattwoberts in forum 1.x Help
    Replies: 1
    Last Post: Jan 04, 2011, 2:56 PM
  2. [CLOSED] [1.0] gridpanel loads blank rows
    By PoloTheMonk in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 02, 2010, 3:54 AM
  3. [CLOSED] Store loads forever
    By pschojer in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Aug 28, 2009, 8:28 AM
  4. [CLOSED] Display modal while grid/page loads
    By bfolger in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 26, 2009, 7:05 PM
  5. Window don't loads correctly in the IE7
    By flaviodamaia in forum 1.x Help
    Replies: 4
    Last Post: Jul 21, 2009, 2:42 PM

Posting Permissions