May 08, 2013, 2:01 AM
[CLOSED] Paging Combobox Filter fn Not Defined
Ext.NET 2.2.0.40838
I am having trouble getting a combo/store to page, what am I doing wrong?
I get a javascript error fn is not defined in Ext.data.proxy.PagingMemory under read function line "isMatch = isMatch && fn.call(scope, record);":
I am having trouble getting a combo/store to page, what am I doing wrong?
I get a javascript error fn is not defined in Ext.data.proxy.PagingMemory under read function line "isMatch = isMatch && fn.call(scope, record);":
Ext.define("Ext.data.proxy.PagingMemory", {
extend : "Ext.data.proxy.Memory",
alias: "proxy.pagingmemory",
isMemoryProxy : true,
read : function (operation, callback, scope) {
var reader = this.getReader(),
result = reader.read(this.data || []),
sorters, filters, sorterFn, records;
if (operation.gridfilters !== undefined) {
var r = [];
for (var i = 0, len = result.records.length; i < len; i++) {
if (operation.gridfilters.call(this, result.records[i])) {
r.push(result.records[i]);
}
}
result.records = r;
result.totalRecords = result.records.length;
}
scope = scope || this;
filters = operation.filters;
if (filters.length > 0) {
records = [];
Ext.each(result.records, function (record) {
var isMatch = true,
length = filters.length,
i;
for (i = 0; i < length; i++) {
var filter = filters[i],
fn = Ext.isFunction(filter) ? filter : filter.filterFn,
scope = filter.scope;
isMatch = isMatch && fn.call(scope, record);
}
if (isMatch) {
records.push(record);
}
}, this);
result.records = records;
result.totalRecords = result.total = records.length;
}
// sorting
sorters = operation.sorters;
if (sorters.length > 0) {
sorterFn = function (r1, r2) {
var result = sorters[0].sort(r1, r2),
length = sorters.length,
i;
for (i = 1; i < length; i++) {
result = result || sorters[i].sort.call(this, r1, r2);
}
return result;
};
result.records.sort(sorterFn);
}
if (operation.start !== undefined && operation.limit !== undefined && operation.isPagingStore !== true) {
result.records = Ext.Array.slice(result.records, operation.start, operation.start + operation.limit);
result.count = result.records.length;
}
Ext.apply(operation, {
resultSet: result
});
operation.setCompleted();
operation.setSuccessful();
//Ext.Function.defer(function () {
Ext.callback(callback, scope, [operation]);
//}, 10);
}
});
Example:<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<script runat="server">
public class State
{
public string StateID { get; set; }
public string StateName { get; set; }
}
protected void Page_Load(Object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
List<State> states = new List<State>()
{
new State(){ StateID = "AK", StateName="ALASKA" },
new State(){ StateID = "AL", StateName="ALABAMA" },
new State(){ StateID = "AR", StateName="ARKANSAS" },
new State(){ StateID = "AZ", StateName="ARIZONA " },
new State(){ StateID = "CA", StateName="CALIFORNIA " },
new State(){ StateID = "CO", StateName="COLORADO " },
new State(){ StateID = "CT", StateName="CONNECTICUT" },
new State(){ StateID = "DC", StateName="DISTRICT OF COLUMBIA" },
new State(){ StateID = "DE", StateName="DELAWARE" },
new State(){ StateID = "FL", StateName="FLORIDA" },
new State(){ StateID = "GA", StateName="GEORGIA" },
new State(){ StateID = "HI", StateName="HAWAII" },
new State(){ StateID = "IA", StateName="IOWA" },
new State(){ StateID = "ID", StateName="IDAHO" },
new State(){ StateID = "IL", StateName="ILLINOIS" },
new State(){ StateID = "IN", StateName="INDIANA" },
new State(){ StateID = "KS", StateName="KANSAS" },
new State(){ StateID = "KY", StateName="KENTUCKY" },
new State(){ StateID = "LA", StateName="LOUISIANA" },
new State(){ StateID = "MA", StateName="MASSACHUSETTS" },
new State(){ StateID = "MD", StateName="MARYLAND" },
new State(){ StateID = "ME", StateName="MAINE" },
new State(){ StateID = "MI", StateName="MICHIGAN" },
new State(){ StateID = "MN", StateName="MINNESOTA" },
new State(){ StateID = "MO", StateName="MISSOURI" },
new State(){ StateID = "MS", StateName="MISSISSIPPI" },
new State(){ StateID = "MT", StateName="MONTANA" },
new State(){ StateID = "NC", StateName="NORTH CAROLINA" },
new State(){ StateID = "ND", StateName="NORTH DAKOTA" },
new State(){ StateID = "NE", StateName="NEBRASKA" },
new State(){ StateID = "NH", StateName="NEW HAMPSHIRE" },
new State(){ StateID = "NJ", StateName="NEW JERSEY" },
new State(){ StateID = "NM", StateName="NEW MEXICO" },
new State(){ StateID = "NV", StateName="NEVADA" },
new State(){ StateID = "NY", StateName="NEW YORK" },
new State(){ StateID = "OH", StateName="OHIO" },
new State(){ StateID = "OK", StateName="OKLAHOMA" },
new State(){ StateID = "OR", StateName="OREGON" },
new State(){ StateID = "PA", StateName="PENNSYLVANIA" },
new State(){ StateID = "RI", StateName="RHODE ISLAND" },
new State(){ StateID = "SC", StateName="SOUTH CAROLINA" },
new State(){ StateID = "SD", StateName="SOUTH DAKOTA" },
new State(){ StateID = "TN", StateName="TENNESSEE" },
new State(){ StateID = "TX", StateName="TEXAS" },
new State(){ StateID = "UT", StateName="UTAH" },
new State(){ StateID = "VA", StateName="VIRGINIA " },
new State(){ StateID = "VT", StateName="VERMONT" },
new State(){ StateID = "WA", StateName="WASHINGTON" },
new State(){ StateID = "WI", StateName="WISCONSIN" },
new State(){ StateID = "WV", StateName="WEST VIRGINIA" },
new State(){ StateID = "WY", StateName="WYOMING" }
};
strStateList.DataSource = states;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Paging Test</title>
</head>
<body>
<form id="frm" runat="server">
<ext:ResourceManager ID="rsMan" runat="server" />
<ext:ComboBox runat="server" ID="cmbState"
FieldLabel="State" Editable="true" SelectOnFocus="false" ForceSelection="true"
QueryMode="Local" DisplayField="StateName" ValueField="StateID" AllowBlank="false" PageSize="10">
<Store>
<ext:Store ID="strStateList" runat="server" PageSize="10" IsPagingStore="true">
<Reader>
<ext:JsonReader />
</Reader>
<Model>
<ext:Model ID="mdlStateList" runat="server" IDProperty="StateID">
<Fields>
<ext:ModelField Name="StateID" />
<ext:ModelField Name="StateName" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:ComboBox>
</form>
</body>
</html>
Last edited by Daniil; May 10, 2013 at 3:26 AM.
Reason: [CLOSED]