CatalystX-CRUD-YUI
view release on metacpan or search on metacpan
lib/CatalystX/CRUD/YUI/TT/static/js/livegrid/src/Toolbar.js view on Meta::CPAN
*/
/**
* @cfg {Ext.grid.GridView} view The view the toolbar is bound to
* The grid the toolbar is bound to. If ommited, use the cfg property "grid"
*/
/**
* @cfg {Boolean} displayInfo
* True to display the displayMsg (defaults to false)
*/
/**
* @cfg {String} displayMsg
* The paging status message to display (defaults to "Displaying {start} - {end} of {total}")
*/
displayMsg : 'Displaying {0} - {1} of {2}',
/**
* @cfg {String} emptyMsg
* The message to display when no records are found (defaults to "No data to display")
*/
emptyMsg : 'No data to display',
/**
* Value to display as the tooltip text for the refresh button. Defaults to
* "Refresh"
* @param {String}
*/
refreshText : "Refresh",
initComponent : function()
{
Ext.ux.grid.livegrid.Toolbar.superclass.initComponent.call(this);
if (this.grid) {
this.view = this.grid.getView();
}
var me = this;
this.view.init = this.view.init.createSequence(function(){
me.bind(this);
}, this.view);
},
// private
updateInfo : function(rowIndex, visibleRows, totalCount)
{
if(this.displayEl){
var msg = totalCount == 0 ?
this.emptyMsg :
String.format(this.displayMsg, rowIndex+1,
rowIndex+visibleRows, totalCount);
this.displayEl.update(msg);
}
},
/**
* Unbinds the toolbar.
*
* @param {Ext.grid.GridView|Ext.gid.GridPanel} view Either The view to unbind
* or the grid
*/
unbind : function(view)
{
var st;
var vw;
if (view instanceof Ext.grid.GridView) {
vw = view;
} else {
// assuming parameter is of type Ext.grid.GridPanel
vw = view.getView();
}
st = view.ds;
st.un('loadexception', this.enableLoading, this);
st.un('beforeload', this.disableLoading, this);
st.un('load', this.enableLoading, this);
vw.un('rowremoved', this.onRowRemoved, this);
vw.un('rowsinserted', this.onRowsInserted, this);
vw.un('beforebuffer', this.beforeBuffer, this);
vw.un('cursormove', this.onCursorMove, this);
vw.un('buffer', this.onBuffer, this);
vw.un('bufferfailure', this.enableLoading, this);
this.view = undefined;
},
/**
* Binds the toolbar to the specified {@link Ext.ux.grid.Livegrid}
*
* @param {Ext.grird.GridView} view The view to bind
*/
bind : function(view)
{
this.view = view;
var st = view.ds;
st.on('loadexception', this.enableLoading, this);
st.on('beforeload', this.disableLoading, this);
st.on('load', this.enableLoading, this);
view.on('rowremoved', this.onRowRemoved, this);
view.on('rowsinserted', this.onRowsInserted, this);
view.on('beforebuffer', this.beforeBuffer, this);
view.on('cursormove', this.onCursorMove, this);
view.on('buffer', this.onBuffer, this);
view.on('bufferfailure', this.enableLoading, this);
},
// ----------------------------------- Listeners -------------------------------
enableLoading : function()
{
this.loading.setDisabled(false);
},
disableLoading : function()
{
this.loading.setDisabled(true);
},
( run in 2.618 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )