Jul 20, 2012, 7:07 AM
[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
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.csusing 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]