PDA

View Full Version : [CLOSED] combox's item can not be selected when the selected item is not the first page?



hdsoso
May 06, 2013, 1:04 AM
combox's item can not be select when the selected item is not the first page?

below is my testcase:



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="TobrosCWT.BasicInfoSetup.WebForm4" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
//tfApAccCode.SelectedItems.Add(new Ext.Net.ListItem("test3", "3"));//it can be selected
tfApAccCode.SelectedItems.Add(new Ext.Net.ListItem("test11", "11"));//it can not be selected? why?
}
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ext:ResourceManager runat="server"></ext:ResourceManager>
<ext:ComboBox ID="tfApAccCode" runat="server" FieldLabel="Acccout" TypeAhead="false" EmptyText="Please select..." ForceSelection="true" DisplayField="Cname" ValueField="Ccode" MinChars="1" MatchFieldWidth="false" PageSize="10">
<Store>
<ext:Store ID="store2" runat="server" IsPagingStore="true" PageSize="10">
<Model>
<ext:Model ID="Model4" runat="server">
<Fields>
<ext:ModelField Name="Ccode" />
<ext:ModelField Name="Cname" />
</Fields>
</ext:Model>
</Model>
<Parameters>
<ext:StoreParameter Name="search" Value="#{tfApAccCode}==null?#{tfApAccCode}:#{tfApAccCode} .getValue()" Mode="Raw"></ext:StoreParameter>
</Parameters>
<Proxy>
<ext:AjaxProxy Url="../BasicInfoAshx/Test.ashx">
<ActionMethods Read="GET" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:Store>
</Store>
<ListConfig Width="320" Height="300" ItemSelector=".x-boundlist-item">
<Tpl ID="Tpl4" runat="server">
<Html>
<tpl for=".">
<tpl if="[xindex] == 1">
<table class="cbStates-list">
<tr>
<th>AccCode</th>
<th>AccName</th>
</tr>
</tpl>
<tr class="x-boundlist-item">
<td>{Ccode}</td>
<td>{Cname}</td>
</tr>
<tpl if="[xcount-xindex]==0">
</table>
</tpl>
</tpl>
</Html>
</Tpl>
</ListConfig>
</ext:ComboBox>
</div>
</form>
</body>
</html>


Test.ashx.cs:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ext.Net;

namespace TobrosCWT.BasicInfoAshx
{
/// <summary>
/// Test
/// </summary>
public class Test : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "application/json";

var requestParams = new StoreRequestParameters(context);

int start = requestParams.Start;
int limit = requestParams.Limit;

var data = GetAllAsPaging(start, limit);
var total = 30;

var suppliers = new Paging<customss>(data, total);

context.Response.Write(JSON.Serialize(suppliers));
}

private List<customss> GetAllAsPaging(int start, int limit)
{
List<customss> o = new List<customss>();
for (int i = 0; i < 30; i++)
{
customss c = new customss();
c.Ccode = i.ToString();
c.Cname = "test" + i;
o.Add(c);
}
return o.Skip(start).Take(limit).ToList<customss>();
}


public bool IsReusable
{
get
{
return false;
}
}
}

class customss
{
public string Ccode;
public string Cname;
}
}

thanks.

Daniil
May 06, 2013, 6:07 AM
Hi @hdsoso,

Yes, if you use remote paging (i.e. a Store loads data for the current page only), then an item from non-active page cannot be selected, because it is just absent.

hdsoso
May 14, 2013, 3:35 AM
Hi @hdsoso,

Yes, if you use remote paging (i.e. a Store loads data for the current page only), then an item from non-active page cannot be selected, because it is just absent.

if there is a lot of data , must paging, how to do ? how to locate the page whch is not the first page?can you modify the code above?

thanks.

Daniil
May 14, 2013, 4:03 AM
I think the following thread can help you.
http://forums.ext.net/showthread.php?22653