Hi!
I want to create a grid where a edit action item is displayed, if the user has sufficient rights (entry based)
What would be a performant architecture for that?
I thought about creating a AuthorizationsStore, where I keep the rights and then have following action item function:
PHP Code:
getClass: function(id,metadata,record,rowIndex,colIndex,store){
// keep a reference for next execution
this.authorizationsStore = Ext.StoreMgr.get('Authorzations');
// get the authorization from the model
var allowed = this.authorizationsStore.isAllowed('edit',id);
// delay rendering
if(allowed===-1) {
// authorization now yet loaded
if(!this.loadingAuthorizations) {
this.loadingAuthorizations = true;
// re-render when available
this.authorizationsStore.on('loaded', {
single: true,
callback: function() {
// re-render columns
this.doLayout(); // (is this working)
// change flag
this.loadingAuthorizations = false;
}
}); //eo on
return 'loading-icon';
}
}
// already loaded, return correct icon
return allowed ? 'edit-icon' : 'x-hide-display';
}
Do you have tips for a better pattern?
thanks
Roland