Results 1 to 3 of 3

Thread: Cleanest way to use Column Renderer with MVC?

  1. #1
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Answers
    67
    Vote Rating
    284
      0  

    Default Cleanest way to use Column Renderer with MVC?

    Hey.

    How are you guys using renderers with MVC? I don't really want to do the logic in the view, but dynamically setting them from the controller seems sorta weird too. The feed-viewer mvc example does it in the view. How do you guys handle it?

    Thanks

  2. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Answers
    67
    Vote Rating
    284
      0  

    Default

    nobody?

  3. #3
    Sencha User friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Answers
    106
    Vote Rating
    27
      0  

    Default

    I typically create a Singleton Renderer class which contains all the renderers used throughout my app.

    Code:
    /**
     * Singleton which encapsulates system-specific renderers.
     */
    Ext.define('Myapp.view.widgets.Renderers', {
      singleton: true,
    
      active: function(value, p, record) {
          var image = null;
          if (value == true) {
            image = 'active.png';
          } else {
            image = 'inactive.png';
          }
          return '<img src="resources/images/' + image + '">';
      },
          
      activeOnly: function(value, p, record)
      {
        var result = '';
        if (value == true) {
          result = '<img src="resources/images/active.png">';
        }
        return result; 
      },
    
      expired: function(value, p, record) {
        var result = '';
        if (value == true) {
          result = true
        }
        return result;
      },
      
      
      locked: function(value, p, record) {
        var result = '';
        if (value) {
          result = '<img src="resources/images/lock.png">';  
        }
        return result;
      },
    
      roleQuickTip: function(value, metaData, record, rowIndex, colIndex, store) {
        metaData.tdAttr = 'data-qtip="' + record.get('description') + '"';
    
        // primary roles get highlighted.
        if (record.get('primaryRole') == 1) {
          value = '<span class="primaryRole">' + value + '</span>';
        }
        return value;
      }
      
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •