Results 1 to 3 of 3

Thread: RowExpander plugin and reliance on 'data'

  1. #1
    Sencha Premium Member
    Join Date
    Mar 2011

    Default RowExpander plugin and reliance on 'data'

    I stumbled across the limitation of the rowexpander plugin not having access to data contained in associations.

    It makes me wonder why is it so common to pass raw 'data' to templates instead of a model directly? I know raw data can be easier to work with and a bit cleaner to look at in the code, but it feels like a break of encapsulation and an unnecessary limitation on what the template can do.

    Concrete Example:
    Consider a model of a Person model which includes a hasMany association to the Vehicle model. The vehicle model is known to have various 'types' (car, truck, bus...) and the model has a helper method to retrieve the records in the store of a given type. For a particular view, we'd like a list of all the people (in a grid) and, when a person is expanded, the list of all the cars (not trucks or buses...) with which they are associated are displayed in a template under the row.

    Seems like a great fit for rowexpander likely a reasonably common use-case.

    Currently, the rowexpander doesn't provide access to the vehicles at all because only the direct properties of person are available. Even if it did provide the data for the entire model (which could be easily accomplished by passing record.getData(true) instead of just 'data'), the template would still need logic to loop over the collection and only display the 'cars'. If instead, the model was passed in directly, the template could simply loop over the results from a call to the helper method responsible for returning the collection of cars.

    Pros and cons of every approach I suppose; with the effort to introduce an MVC architecture I'd hope the framework (and plugins!) would try to leverage the model more directly.

    I can address the issue easily enough by overriding getRowBodyFeatureData() and passing record instead of data...but is this something Sencha could/would address at some point?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL


    Passing a Model instance is too heavy, XTemplate is setup to use a flat object/array/etc not a class.

    But you can always create an extension to handle associations, I did.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha Premium Member
    Join Date
    Mar 2011


    Ok. What is it about XTemplates that make it unsuitable for a class? You mention a model is too heavy -- does that mean there are performance problems or something of that nature when passing a model to an XTemplate?

    And when you say "extension to handle associations" do you mean you implemented a generic alteration that provides the data of the associations as part of the data an xtemplate compiler extension? Or were you referring to some other technique of accomplishing the goal?

    We were thinking about something like:

    Ext.define('Ext.ux.XTemplateCompiler', {
        extend: 'Ext.XTemplateCompiler',
        doFor: function (action, actions) {
            this.body.push('if (values.modelName && values.getData) { values=values.getData(true); }');
    But I'm still curious what makes a model too "heavy"/inappropriate as an input to an XTemplate. It appears to "work" (ie, if you pass a model you can interact with it the way you'd expect...).

Posting Permissions

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