Oct 15, 2010, 8:55 PM
Mantain PagingToolbar of Templated ComboBox Without Use Count
Hi,
I have the following code:
Maintain the pagingtoolbar without the empty City.
I think, if manipulating the template i can do that, but i don't know how manipulate this, if you have any ideias?
Thanks in advance,
I have the following code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="TreeGridExample.WebForm3" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected int TotalOnDemand
{
get { return Convert.ToInt32(ViewState["TotalOnDemand"]); }
set { ViewState["TotalOnDemand"] = value; }
}
public class City
{
public int ID { get; set; }
public string Name { get; set; }
}
private List<City> cities = new List<City>();
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 1; i < 15; i++)
{
cities.Add(new City { ID = i, Name = "City" + 1 });
}
}
protected void _strCities_RefreshData(object sender, StoreRefreshDataEventArgs e)
{
int contador = 0;
IList<City> lst = cities.Skip(e.Start).Take(e.Limit).ToList();
if (lst.Any())
{
contador = e.Start + e.Limit * 2;
if (contador > TotalOnDemand)
{
TotalOnDemand = contador;
}
}
else
{
if (e.Start > 0)
{
lst = new List<City> { new City() };
}
else
{
TotalOnDemand = 0;
}
}
_strCities.DataSource = lst;
(this._strCities.Proxy[0] as PageProxy).Total = TotalOnDemand;
_strCities.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></title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Store ID="_strCities" runat="server" AutoLoad="false" EnableViewState="true"
OnRefreshData="_strCities_RefreshData">
<DirectEventConfig ViewStateMode="Enabled" />
<Proxy>
<ext:PageProxy />
</Proxy>
<Reader>
<ext:JsonReader IDProperty="ID">
<Fields>
<ext:RecordField Name="ID" Mapping="ID" Type="Int" />
<ext:RecordField Name="Name" Mapping="Name" Type="String" />
</Fields>
</ext:JsonReader>
</Reader>
<Listeners>
<LoadException Handler="Ext.Msg.alert('Employees - Load failed', e.message || response.statusText);" />
</Listeners>
</ext:Store>
<ext:ComboBox ID="_cbCities" runat="server" StoreID="_strCities" ViewStateMode="Enabled"
FieldLabel="City" DisplayField="Name" ValueField="ID" TypeAhead="false" LoadingText="Retrieving Cities.."
Width="400" PageSize="5" ItemSelector="tr.list-item" TriggerAction="Query" MinChars="1"
AllowBlank="false">
<Template ID="Template1" runat="server">
<Html>
<tpl for=".">
<tpl if="[xindex] == 1">
<table class="cbStates-list">
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</tpl>
<tr class="list-item">
<td style="padding:3px 0px;">{ID}</td>
<td>{Name}</td>
</tr>
<tpl if="[xcount-xindex]==0">
</table>
</tpl>
</tpl>
</Html>
</Template>
</ext:ComboBox>
</form>
</body>
</html>
So, in this approach i can maintain the pagingtoolbar with one City with nothing on the final page, but i need a better approach:Maintain the pagingtoolbar without the empty City.
I think, if manipulating the template i can do that, but i don't know how manipulate this, if you have any ideias?
Thanks in advance,