﻿
Ext.apply(Ext.data.Store.prototype, {
  load : function(options){
        options = options || {};
        if(this.fireEvent("beforeload", this, options) !== false){
            this.storeOptions(options);
            var p = Ext.apply(options.params || {}, this.baseParams);
//richard
                 p['_dcx']=   (new Date().getTime());
//end richard
            if(this.sortInfo && this.remoteSort){
                var pn = this.paramNames;
                p[pn["sort"]] = this.sortInfo.field;
                p[pn["dir"]] = this.sortInfo.direction;
            }
           
            this.proxy.load(p, this.reader, this.loadRecords, this, options);
        }
    }
});

Ext.apply(Ext.LayoutRegion.prototype,{
  updatePanelTitle : function(panel, title){
        if(this.activePanel == panel){
            this.updateTitle(title);
        }
/*Richard    
        if(this.tabs){
            var ti = this.tabs.getTab(panel.getEl().id);
            ti.setText(title);
            if(panel.tabTip !== undefined){
                ti.setTooltip(panel.tabTip);
            }
        }
*/
    }
});

Ext.override(Ext.PagingToolbar, {
    addPageSizer: function() {
    
      this.pageSize = 40

	    var store = new Ext.data.SimpleStore({
	        fields: ['pageSize'],
	        data : [[10],[20],[40],[60],[100]]
	    });
	    var combo = new Ext.form.ComboBox({
	    	  store: store,
	        displayField:'pageSize',
	        editable:false,
	        typeAhead: false,
	        mode: 'local',
	        value:'40',
	        triggerAction: 'all',
	        selectOnFocus:true,
	        width:45
	    });
	    
	    this.add('-','Pagesize '); 

	    this.addField(combo);
	    combo.on("change", function(c, value)
	    {
	    	this.pageSize = value;
	    	this.onClick("refresh");
	    }, this);
	    combo.on("select", function(c, record)
	    {
	    	this.pageSize = record.get("pageSize");
	    	this.onClick("refresh");
	    }, this);
	},
	
	  unbind : function(){
	      var ds = this.ds;
        ds.un("beforeload", this.beforeLoad, this);
        ds.un("load", this.onLoad, this);
        ds.un("loadexception", this.onLoadError, this);
        this.ds = undefined;
    },

    
    bind : function(ds){
        ds.on("beforeload", this.beforeLoad, this);
        ds.on("load", this.onLoad, this);
        ds.on("loadexception", this.onLoadError, this);
        this.ds = ds;
    }
});

