1. #1
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    580
    Vote Rating
    269
    Answers
    62
    Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of

      0  

    Default Unanswered: 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
    580
    Vote Rating
    269
    Answers
    62
    Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of Tim Toady has much to be proud of

      0  

    Default

    nobody?

  3. #3
    Sencha - Community Support Team friend's Avatar
    Join Date
    Apr 2011
    Posts
    895
    Vote Rating
    27
    Answers
    106
    friend has a spectacular aura about friend has a spectacular aura about

      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;
      }
      
    });

Thread Participants: 1