[CLOSED] Paging Combobox Filter fn Not Defined

  1. #1

    [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);":
    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]
  2. #2
    Hi @ltctech,

    Your example runs without any error for me. I use the Ext.NET sources from the trunk and FireFox.
    Ext.NET 2.2.0.40838
    The last numbers doesn't allow us to determine what actual Ext.NET version you are using. Those numbers depends on build time.
    Version numbers in a compiled assembly

    So, are you using v2.2 release or the SVN trunk?
  3. #3
    I am using the latest release pulled from Nuget.
    Will compile trunk tomorrow; it probably has been fixed if it runs fine for you.

    I like the Nuget releases as VS tells me when there are updates, don't have to copy stuff from one project to another.
    Have you guys considered a rapid release cycle for Nuget?
    I think you can mark builds as beta if you need.
  4. #4
    I was able to reproduce with v2.2. So, yes, it appears to be fixed after v2.2 release.

    Quote Originally Posted by ltctech View Post
    Have you guys considered a rapid release cycle for Nuget?
    I have asked our manager about it.
  5. #5
    Quote Originally Posted by ltctech View Post
    I like the Nuget releases as VS tells me when there are updates, don't have to copy stuff from one project to another.
    Have you guys considered a rapid release cycle for Nuget?
    I think you can mark builds as beta if you need.
    It's possible, but I'll have to think about it. We'll probably have to stick with Major and Minor version releases for now.

    Would be cool to release nightly through NuGet too, but that would really clog up our NuGet page fast.
    Geoffrey McGill
    Founder
  6. #6
    Ok, trunk version allows paging.

    I have another problem now.
    When you type a query and select something, you cannot clear the query and search for something else.
    The list that comes up is simply empty.
    Is this another bug?
  7. #7
    You are right, it is another bug. For now, please use the following fix.

    Fix
    Ext.data.PagingStore.override({
        filter: function (filters, value) {
            if (Ext.isString(filters)) {
                filters = {
                    property: filters,
                    value: value
                };
            }
    
            var me = this,
                decoded = me.decodeFilters(filters),
                i,
                doLocalSort = me.sorters.length && me.sortOnFilter && !me.remoteSort,
                length = decoded.length;
    
            for (i = 0; i < length; i++) {
                me.filters.replace(decoded[i]);
            }
    
            if (me.remoteFilter) {
                delete me.totalCount;
                
                if (me.buffered) {
                    me.data.clear();
                    me.loadPage(1);
                } else {
                    me.currentPage = 1;
                    me.load();
                }
            } else {
                if (me.filters.getCount()) {
                    me.snapshot = me.snapshot || me.allData || me.data.clone();
                    //me.data = (me.allData || me.snapshot).filter(me.filters.items);
                    me.data = (me.snapshot || me.allData).filter(me.filters.items);
                    
                    me.constructGroups();
    
                    if (doLocalSort) {
                        me.sort();
                        me.applyPaging();
                    } else {
                        me.applyPaging();
                        // fire datachanged event if it hasn't already been fired by doSort
                        me.fireEvent('datachanged', me);
                        me.fireEvent('refresh', me);
                    }
                }
            }
            
            me.fireEvent('filterchange', me, me.filters.items);
        }
    });
  8. #8
    The fix has been committed to SVN. Thank you for the report.
  9. #9
    Works, Thanks.

Similar Threads

  1. [CLOSED] paging toolbar loses filter params when paging
    By ecko in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Mar 08, 2013, 10:15 AM
  2. Replies: 3
    Last Post: Mar 22, 2012, 7:46 AM
  3. Paging toolbar refresh after filter
    By dan182 in forum 1.x Help
    Replies: 6
    Last Post: Dec 28, 2011, 9:48 AM
  4. Gridpanel Paging and Filter Problem.
    By Ganesh3.shirsath in forum 1.x Help
    Replies: 0
    Last Post: Feb 15, 2011, 7:16 AM
  5. Filter vs. GridPanel Paging
    By reiben in forum 1.x Help
    Replies: 3
    Last Post: Dec 09, 2010, 6:07 PM

Posting Permissions