genius551v
22 Jan 2008, 7:03 AM
Hello,
This is just a little example of a global loading indicator to ajax request.
/**
* @class Ext.ux.indicator
* @extends Ext.Button
*/
Ext.ux.indicator = Ext.extend(Ext.Button, {
iconCls: 'icon-indicator-static',
disabled: true,
counter : 0,
initComponent : function() {
Ext.ux.AutoGridPanel.superclass.initComponent.call(this);
Ext.Ajax.on('beforerequest', function(conn, o){
//if(o.isUpload) return;
if(this.counter == 0)
this.showProgress();
++this.counter;
}, this);
Ext.Ajax.on('requestcomplete', function(conn, response, o){
//if(o.isUpload) return;
--this.counter;
if(this.counter <= 0)
this.hideProgress();
}, this);
Ext.Ajax.on('requestexception', function(conn, response, o){
alert('requestexception');
//if(o.isUpload) return;
--this.counter;
this.hideProgress();
}, this);
},
showProgress: function() {
this.setIconClass('icon-indicator');
},
hideProgress: function() {
this.setIconClass('icon-indicator-static');
},
handler : function() {
alert(this.counter);
}
});
implementation:
tbar: [{
text: 'Button1',
iconCls: 'icon1',
tooltip: 'This is a button1',
handler : YourHandlerFunction
},{
text: 'Button2',
iconCls: 'icon2',
tooltip: 'This is a button2',
handler : YourHandlerFunction
},
'->',
new Ext.ux.indicator()
],
Tnks to bahar in digitalbucket.net and www.ajaxload.info
(remenber change the path to the images for you configuration path)
your comments are wellcome...be nice please :D
This is just a little example of a global loading indicator to ajax request.
/**
* @class Ext.ux.indicator
* @extends Ext.Button
*/
Ext.ux.indicator = Ext.extend(Ext.Button, {
iconCls: 'icon-indicator-static',
disabled: true,
counter : 0,
initComponent : function() {
Ext.ux.AutoGridPanel.superclass.initComponent.call(this);
Ext.Ajax.on('beforerequest', function(conn, o){
//if(o.isUpload) return;
if(this.counter == 0)
this.showProgress();
++this.counter;
}, this);
Ext.Ajax.on('requestcomplete', function(conn, response, o){
//if(o.isUpload) return;
--this.counter;
if(this.counter <= 0)
this.hideProgress();
}, this);
Ext.Ajax.on('requestexception', function(conn, response, o){
alert('requestexception');
//if(o.isUpload) return;
--this.counter;
this.hideProgress();
}, this);
},
showProgress: function() {
this.setIconClass('icon-indicator');
},
hideProgress: function() {
this.setIconClass('icon-indicator-static');
},
handler : function() {
alert(this.counter);
}
});
implementation:
tbar: [{
text: 'Button1',
iconCls: 'icon1',
tooltip: 'This is a button1',
handler : YourHandlerFunction
},{
text: 'Button2',
iconCls: 'icon2',
tooltip: 'This is a button2',
handler : YourHandlerFunction
},
'->',
new Ext.ux.indicator()
],
Tnks to bahar in digitalbucket.net and www.ajaxload.info
(remenber change the path to the images for you configuration path)
your comments are wellcome...be nice please :D