1. #1
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    581
    Vote Rating
    9
    Dumas will become famous soon enough

      0  

    Default Action Item rendering with serverside data

    Action Item rendering with serverside data


    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', {
                    
    singletrue,
                    
    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

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    I am not sure I would check authorization level on each render call, that could be very expensive. I would suggestdrawing the icons and using the handler to allow/deny access at time of click.

    Regards,
    Scott.

  3. #3
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    581
    Vote Rating
    9
    Dumas will become famous soon enough

      0  

    Default


    Hello!

    Yeah, I figured out the same, now I'm checking on icon-click...

    thanks
    Roland

Thread Participants: 1