function jsExtPagingToolbarEx()
{

};
/*网格属性对象*/
jsExtPagingToolbarEx.GridAttributeGroup=null;
/*是否加载完毕标志*/
jsExtPagingToolbarEx.IsLoaded=false;
jsExtPagingToolbarEx.strSql="";
jsExtPagingToolbarEx.GridID="";
jsExtPagingToolbarEx.pagingBarID="";
/*初始化网格数据属性*/
jsExtPagingToolbarEx.initGrid=function(GridID,pagingBarID,strSql)
{
    try
    {
        if(jsExtPagingToolbarEx.GridAttributeGroup==null)
        {
            jsExtPagingToolbarEx.GridAttributeGroup=new Array();
        }
        var strAttributeObj={GridID:GridID,pagingBarID:pagingBarID,Sql:strSql};
        jsExtPagingToolbarEx.GridAttributeGroup.push(strAttributeObj);
        /*调用了该方法就表示已经加载完毕*/
        jsExtPagingToolbarEx.IsLoaded=true;
    }
    catch(e)
    {
        alert("jsExtPagingToolbarEx.initGrid:"+e.message);
    }
    CollectGarbage();
};
/*初始化分页控件*/
jsExtPagingToolbarEx.init=function()
{
    try
    {
        Ext.PagingToolbarEx = Ext.extend(Ext.PagingToolbar, {
            moveFirst: function() {
                if(jsExtPagingToolbarEx.IsLoaded==true)//jsExtPagingToolbarEx.strSql!="" && jsExtPagingToolbarEx.pagingBarID!="")
                {
                    var obj=event.srcElement;
                    var PagerObj=eval("obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement");
                    var pagingBarID=PagerObj.id;
                    PagerObj=null;
                    var SqlString="";
                    var GridID="";
                    if(jsExtPagingToolbarEx.GridAttributeGroup!=null)
                    {
                        for(var i=0;i<jsExtPagingToolbarEx.GridAttributeGroup.length;i++)
                        {
                            if(jsExtPagingToolbarEx.GridAttributeGroup[i].pagingBarID==pagingBarID)
                            {
                                SqlString=jsExtPagingToolbarEx.GridAttributeGroup[i].Sql;
                                GridID=jsExtPagingToolbarEx.GridAttributeGroup[i].GridID;
                            }
                        }
                    }
                    
                    var pagingBar=Ext.getCmp(pagingBarID);//(jsExtPagingToolbarEx.pagingBarID);
                    if(pagingBar!=undefined && pagingBar!=null)
                    {
                        pagingBar.doLoad(0);
                        var _nowPageIndex=parseInt(pagingBar.inputItem.value);
                        var total = pagingBar.store.getTotalCount();
                    }
                    jsExtPagingToolbarEx.paged(_nowPageIndex,this.pageSize,total,SqlString,GridID,pagingBarID);
                }
                //                alert("第一页");
            },
            movePrevious: function() {
                if(jsExtPagingToolbarEx.IsLoaded==true)//jsExtPagingToolbarEx.strSql!="")
                {
                    var obj=event.srcElement;
                    var PagerObj=eval("obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement");
                    var pagingBarID=PagerObj.id;
                    PagerObj=null;
                    var SqlString="";
                    var GridID="";
                    if(jsExtPagingToolbarEx.GridAttributeGroup!=null)
                    {
                        for(var i=0;i<jsExtPagingToolbarEx.GridAttributeGroup.length;i++)
                        {
                            if(jsExtPagingToolbarEx.GridAttributeGroup[i].pagingBarID==pagingBarID)
                            {
                                SqlString=jsExtPagingToolbarEx.GridAttributeGroup[i].Sql;
                                GridID=jsExtPagingToolbarEx.GridAttributeGroup[i].GridID;
                            }
                        }
                    }
                    
                    this.doLoad(Math.max(0, this.cursor - this.pageSize));
                    var _nowPageIndex=parseInt(this.inputItem.value);
                    var total = this.store.getTotalCount();
                    jsExtPagingToolbarEx.paged(_nowPageIndex,this.pageSize,total,SqlString,GridID,pagingBarID);                    
                }
                //                alert("上一页");
            },
            moveNext: function() {
                if(jsExtPagingToolbarEx.IsLoaded==true)//jsExtPagingToolbarEx.strSql!="")
                {
                    var obj=event.srcElement;
                    var PagerObj=eval("obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement");
                    var pagingBarID=PagerObj.id;
                    PagerObj=null;
                    var SqlString="";
                    var GridID="";
                    if(jsExtPagingToolbarEx.GridAttributeGroup!=null)
                    {
                        for(var i=0;i<jsExtPagingToolbarEx.GridAttributeGroup.length;i++)
                        {
                            if(jsExtPagingToolbarEx.GridAttributeGroup[i].pagingBarID==pagingBarID)
                            {
                                SqlString=jsExtPagingToolbarEx.GridAttributeGroup[i].Sql;
                                GridID=jsExtPagingToolbarEx.GridAttributeGroup[i].GridID;
                            }
                        }
                    }
                    
                    this.doLoad(this.cursor + this.pageSize);
                    var total = this.store.getTotalCount();
                    var _nowPageIndex=parseInt(this.inputItem.value);
                    jsExtPagingToolbarEx.paged(_nowPageIndex,this.pageSize,total,SqlString,GridID,pagingBarID);
                }
                //                alert("下一页");
            },
            moveLast: function() {
                if(jsExtPagingToolbarEx.IsLoaded==true)//jsExtPagingToolbarEx.strSql!="")
                {
                    var obj=event.srcElement;
                    var PagerObj=eval("obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement");
                    var pagingBarID=PagerObj.id;
                    PagerObj=null;
                    var SqlString="";
                    var GridID="";
                    if(jsExtPagingToolbarEx.GridAttributeGroup!=null)
                    {
                        for(var i=0;i<jsExtPagingToolbarEx.GridAttributeGroup.length;i++)
                        {
                            if(jsExtPagingToolbarEx.GridAttributeGroup[i].pagingBarID==pagingBarID)
                            {
                                SqlString=jsExtPagingToolbarEx.GridAttributeGroup[i].Sql;
                                GridID=jsExtPagingToolbarEx.GridAttributeGroup[i].GridID;
                            }
                        }
                    }
                    
                    var total = this.store.getTotalCount();
                    extra = total % this.pageSize;
                    var count = 0;
                    if (extra > 0) {
                        count = total / this.pageSize + 1;
                    } else {
                        count = total / this.pageSize;
                    }
                    this.doLoad(extra ? (total - extra) : total - this.pageSize);
                    var _nowPageIndex=parseInt(this.inputItem.value);
                    jsExtPagingToolbarEx.paged(_nowPageIndex,this.pageSize,total,SqlString,GridID,pagingBarID);
                }
                //                alert("最后一页");
            },
            doRefresh: function() {
                if(jsExtPagingToolbarEx.IsLoaded==true)//jsExtPagingToolbarEx.strSql!="")
                {
                    var obj=event.srcElement;
                    var PagerObj=eval("obj.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement");
                    var pagingBarID=PagerObj.id;
                    PagerObj=null;
                    var SqlString="";
                    var GridID="";
                    if(jsExtPagingToolbarEx.GridAttributeGroup!=null)
                    {
                        for(var i=0;i<jsExtPagingToolbarEx.GridAttributeGroup.length;i++)
                        {
                            if(jsExtPagingToolbarEx.GridAttributeGroup[i].pagingBarID==pagingBarID)
                            {
                                SqlString=jsExtPagingToolbarEx.GridAttributeGroup[i].Sql;
                                GridID=jsExtPagingToolbarEx.GridAttributeGroup[i].GridID;
                            }
                        }
                    }
                    
                    var _nowPageIndex = parseInt(this.inputItem.value);
                    var total = this.store.getTotalCount();
                    var extra = total % this.pageSize;
                    var count = 0;
                    if (extra > 0) {
                        count = total / this.pageSize + 1;
                    } else {
                        count = total / this.pageSize;
                    }
                    var MaxPageIndex=extra ? (total - extra) : total - this.pageSize;                    
//                    if(_nowPageIndex>=extra)
//                    {
//                        this.doLoad(MaxPageIndex);
//                    }
//                    else
//                    {
//                        if(_nowPageIndex>1)
//                        {
//                            this.doLoad((_nowPageIndex)*this.pageSize);
//                        }
//                        else
//                        {
                            this.doLoad((_nowPageIndex-1)*this.pageSize);
//                        }
//                    }
                    _nowPageIndex = parseInt(this.inputItem.value);
                    jsExtPagingToolbarEx.paged(_nowPageIndex,this.pageSize,total,SqlString,GridID,pagingBarID);
                }                    
                //                alert("刷新");
            }
        });
    }
    catch(e)
    {
        alert("jsExtPagingToolbarEx.init:"+e.message);        
    }
    CollectGarbage();
};
/*分页动作*/
/*
参数说明：
strSql：查询的SQL语句
pagesize：一页有多少条数据
pageindex：第几页
*/
jsExtPagingToolbarEx.paged=function(pageindex,pagesize,totalCount,SqlString,GridID,pagingBarID)
{
    try
    {
        if(typeof(SqlString)!="undefined" && SqlString!="")
        {
            jsExtPagingToolbarEx.strSql=SqlString;
        }
        if(typeof(GridID)!="undefined" && GridID!="")
        {
            jsExtPagingToolbarEx.GridID=GridID;
        }
        if(typeof(pagingBarID)!="undefined" && pagingBarID!="")
        {
            jsExtPagingToolbarEx.pagingBarID=pagingBarID;
        }
        
        if(jsExtPagingToolbarEx.strSql!="" && jsExtPagingToolbarEx.GridID!="" && jsExtPagingToolbarEx.pagingBarID!="")
        {
            var pagingBar=Ext.getCmp(jsExtPagingToolbarEx.pagingBarID);
            var count = 0;//页码
            if (typeof(totalCount) != "undefined") 
            {
                count = totalCount;
            }
            else
            {
                if(pagingBar!=undefined && pagingBar!=null)
                {
                    count = parseInt(pagingBar.inputItem.value); //jsExtPagingToolbarEx.pagingBar.inputItem.value 为页码文本框的值
                }
            }
//            alert(jsExtPagingToolbarEx.strSql+","+pagesize+","+pageindex);
            data=jsJsonData.getListPagerSqlData(jsExtPagingToolbarEx.strSql+","+pagesize+","+pageindex);
            var StoreData=data[0];
            var columGroup=data[1];
            data=null;
            var store = new Ext.data.Store({
            proxy: new Ext.ux.data.PagingMemoryProxy(StoreData),
            reader: new Ext.data.JsonReader({
                    totalProperty: 'total', 
                    root: 'root'
                },columGroup)
            });
            columGroup=null;
            if (StoreData!=null && typeof(StoreData)!="undefined" && typeof(StoreData.root) != "undefined" && StoreData.root != null && pagingBar!=null && pagingBar!=undefined) 
            {
                pagingBar.displayItem.setText("显示第 " + ((pageindex - 1) * pagesize + 1) + " 条到 " + (StoreData.root.length + (pageindex - 1) * pagesize) + " 条记录,共 " + StoreData.total + " 条");
            } 
            else 
            {
//                alert(StoreData.returnval);
            }
            var grid=Ext.getCmp(jsExtPagingToolbarEx.GridID);
            grid.reconfigure(store, grid.colModel);//重新梆定数据源跟列
            
            store.load();
            
            StoreData.root=null;
            StoreData=null;
            store=null;
            grid=null;
            pagingBar=null;
        }
    }
    catch(e)
    {
//        alert("jsExtPagingToolbarEx.paged:"+e.message);
    }
    CollectGarbage();
};