1. #1
    Sencha User
    Join Date
    Apr 2011
    Posts
    31
    Vote Rating
    0
    Dengqiao Huang is on a distinguished road

      0  

    Default [4.1 B1]Bug in guaranteeRange

    [4.1 B1]Bug in guaranteeRange


    Code:
    Code:
                start = Math.min(Math.max(start - me.numFromEdge - ((me.leadingBufferZone - me.trailingBufferZone) / 2), 0), me.totalCount - me.pageSize);
                end = start + (me.pageSize - 1);
    
                startPage = me.getPageFromRecordIndex(start);
                endPage = me.getPageFromRecordIndex(end);
    Calculated from the new "start" and "end", leading to "startPage" and "endPage" error, can not load data. After I block out ,It's OK.

    Case:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <title></title>
        <link rel="stylesheet" type="text/css" href="../../Ext4/resources/css/ext-all.css"/>
        <script type="text/javascript" src="../../Ext4/bootstrap.js"></script>
        <script type="text/javascript" src="../../Ext4/locale/Ext-lang-zh_CN.js"></script>
        <style type="text/css">
        </style>
    </head>
    <body>    
        <script type="text/javascript">
    
            Ext.define('Orders', {
                extend: 'Ext.data.Model',
                fields: [
                    {name:'OrderID',type:"int"},
                    'CustomerID','CustomerName',
                    {name:'OrderDate',type:"date",format:"Y-m-d"}
                ],
                idProperty:"OrderID"
            });
    
    
            Ext.onReady(function(){
                if(Ext.BLANK_IMAGE_URL.substr(0,4)!="data"){                
                    Ext.BLANK_IMAGE_URL="./images/s.gif";
                }
    
                var store=Ext.create("Ext.data.Store",{
                    model:'Orders',
                    pageSize:100,
                    remoteFilter:true,
                    remoteSort:true,
                    buffered:true,
                    proxy: {
                        type: 'ajax',
                        api:{
                            read:'Orders.ashx'
                            //read:"/Chapter10/Orders" //java
                        },                    
                        reader:{
                            type: 'json',
                            root:"data"
                        }
                    },
                    storeId:"OrdersStore",
                    listeners:{
                        datachanged:function(store){
                            if(store.MyFilter){
                                var grid=Ext.getCmp("myGrid");
                                store.MyFilter=false;
                                grid.invalidateScroller();
                            }
                        }
                    }
                })
                
                Ext.create("Ext.grid.Panel",{
                    id:"myGrid",
                    renderTo:Ext.getBody(),
                    title:"Order List",
                    height:500,
                    width:800,
                    renderTo:Ext.getBody(),
                    store:"OrdersStore",
                    scroll:"both",
                    invalidateScrollerOnRefresh: false,
                    disableSelection:true,
                    tbar:[
                        "Range:",
                        {xtype:"datefield",width:120,id:"StartDate",format:"Y-m-d",value:new Date()},
                        "-",
                        {xtype:"datefield",width:120,id:"EndDate",format:"Y-m-d",value:new Date()},
                        {text:"Go",handler:function(){
                            var grid=this.up("gridpanel"),
                                stroe=grid.store,
                                start=Ext.getCmp("StartDate").getValue(),
                                end=Ext.getCmp("EndDate").getValue(),
                                params=store.getProxy().extraParams;
                                if(start>end){
                                    Ext.Msg.alert("提示信息","开始日期不能大于结束日期!");
                                    return;
                                }else if(start.getTime()==end.getTime()){
                                    params.op="=";
                                }else{
                                    params.op="between";
                                    params.EndDate=Ext.Date.format(end,"Y-m-d");
                                }
                                params.StartDate=Ext.Date.format(start,"Y-m-d");
                                store.prefetchData.clear(); 
                                store.MyFilter=true;
                                if(store.currentPage==1){
                                    store.load();
                                }else{
                                    store.guaranteeRange(0,99);
                                }
                        }},
                        {text:"Show All",handler:function(){
                            var grid=this.up("gridpanel");
                                stroe=grid.store,
                                params=store.getProxy().extraParams;
                                params.op="";
                                params.EndDate="";
                                params.StartDate="";
                                grid.store.prefetchData.clear();
                                grid.store.MyFilter=true;
                                if(store.currentPage==1){
                                    store.load();
                                }else{
                                    store.guaranteeRange(0,99);
                                }
                        }}
                    ],
                    columns:[
                        {xtype:"rownumberer",sortable:false,width:60},
                        {text:'ID',dataIndex:'OrderID'},
                        {text:'Customer ID',dataIndex:'CustomerID'},
                        {text:'Customer',dataIndex:'CustomerName',sortable:false,flex:1},
                        {xtype:"datecolumn",text:'Order Date',dataIndex:'OrderDate',format:"Y-m-d",width:100}
                    ]
                });
                store.guaranteeRange(0,99);
            });
        </script>
    </body>
    </html>

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    There is a bug reported that guaranteeRange needs to be improved.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Posts
    8
    Vote Rating
    0
    hakana is on a distinguished road

      0  

    Exclamation Bug in extjs41 guaranteeRange

    Bug in extjs41 guaranteeRange


    I'm not sure if this is the same issue. But when I call the guaranteeRange the
    me.totalCount is undefined and start get undefined and that broke the function later.

    start = Math.min(Math.max(start - me.numFromEdge - ((me.leadingBufferZone - me.trailingBufferZone) / 2), 0), me.totalCount - me.pageSize)

Thread Participants: 2