added sonia.rest.Grid

This commit is contained in:
Sebastian Sdorra
2010-11-08 20:10:20 +01:00
parent 0fd3f15125
commit f041ae4bb0
3 changed files with 89 additions and 105 deletions

View File

@@ -33,23 +33,10 @@
Ext.ns('Sonia.user');
// UserGrid
Sonia.user.Grid = Ext.extend(Ext.grid.GridPanel, {
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
initComponent: function(){
var selectionModel = new Ext.grid.RowSelectionModel({
singleSelect: true
});
selectionModel.on({
selectionchange: {
scope: this,
fn: this.selectionChanged
}
});
var userStore = new Sonia.rest.JsonStore({
url: restUrl + 'users.json',
root: 'users',
@@ -74,43 +61,19 @@ Sonia.user.Grid = Ext.extend(Ext.grid.GridPanel, {
});
var config = {
loadMask: true,
store: userStore,
colModel: userColModel,
sm: selectionModel
colModel: userColModel
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
// load data
if ( debug ){
console.debug( 'load user list' );
}
userStore.load();
},
reload: function(){
if ( debug ){
console.debug('reload store');
}
this.store.load();
},
selectionChanged: function(sm){
var selected = sm.getSelected();
if ( selected ){
if ( debug ){
console.debug( selected.data.name + ' selected' );
}
}
},
renderMailto: function(mail){
return String.format( this.mailtoTemplate, mail );
selectItem: function(item){
console.debug( item );
}
});
// register xtype
Ext.reg('userGrid', Sonia.user.Grid);
Ext.reg('userGrid', Sonia.user.Grid);