Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:42:59+00:00 2026-06-10T08:42:59+00:00

Say, we have the following in a store: { document: { success: true, totalAllocation:

  • 0

Say, we have the following in a store:

{
    "document": {
        "success": "true",
        "totalAllocation": "40000000.00",
        "fundAllocation": [
            {
                "fundName": "Zais Opportunity Ltd Class B",
                "allocation": "10000000.00"
            },
            {
                "fundName": "Metacapital Mortgage Opportunities Ltd",
                "allocation": "10000000.00"
            },
            ...
        ]
    }
}

And what I’d like to do is something like this:

itemTpl: Ext.create('Ext.XTemplate',
    '<div>',
        '<span>{fundName}</span>',
        '<span>{[this.getPercentage(values.allocation, parent.totalAllocation)]}%</span>',
    '</div>',
    {
        getPercentage: function (allocation, totalAllocation) {
            return Ext.Number.toFixed(allocation / totalAllocation, 2);
        }
    }
)

But, of course, this doesn’t work since ‘parent’ in this scope is empty.

Any idea how to fetch the value of the totalAllocation field inside XTemplate’s fundtion to display the percentage allocated to the current fund in a list item?
Workarounds are welcomed as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:43:01+00:00Added an answer on June 10, 2026 at 8:43 am

    From your data code it looks like document is the store root because there is a success property underneath it. Assuming that is the case, you can use the store reader’s rawData property to get a reference to the value before you create the template. Then you can simply use the referenced value in the getPercentage function.

    Your code does not show where you are creating this itemTpl in your class so I am assuming that you are creating this itemTpl inside the initComponent of the view you are instantiating.

    I have no idea what type of component you are trying to create here other than the fact that it has an itemTpl config property which could be any subclass of Ext.view.AbstractView.

    So I will assume that you are trying to use this in a gridpanel’s view because that is the most common subclass of Ext.view.AbstractView.

    Here’s some code examples.

    Example 1:

    Ext.define('YourApp.view.TemplateGrid', {
        extend: 'Ext.grid.Panel',
    
        // column configs etc...
    
        initComponent: function() {
            var me = this,
                templateStore = Ext.getStore('TemplateStoreId'),
                totalAllocation = templateStore.proxy.reader.rawData.totalAllocation;
    
            me.viewConfig.itemTpl = Ext.create('Ext.XTemplate',
                '<div>',
                    '<span>{fundName}</span>',
                    '<span>{[this.getPercentage(values.allocation)]}%</span>',
                '</div>',
                {
                    getPercentage: function (allocation) {
                        return Ext.Number.toFixed(allocation / totalAllocation, 2);
                    }
                }
            )
        }
    });
    

    Example 1 wouldn’t work if you want to be able to load the store again (after initialization), it also assumes that your view store is already loaded. Here’s another example showing the component set-up to handle multiple loads of the store without being recreated, it also assumes that the store is not loaded at the time when you create the view:

    Example 2

    Ext.define('YourApp.view.TemplateGrid', { // or whatever you are calling it
        extend: 'Ext.grid.Panel',
    
        // column configs etc...
    
        totalAllocation = 0, // add this as a view property
    
        initComponent: function() {
            var me = this,
                templateStore = Ext.create('YourApp.store.TemplateStore');
    
            templateStore.on('load', function() {
                me.totalAllocation = templateStore.proxy.reader.rawData.totalAllocation;
            }
    
            me.viewConfig.itemTpl = Ext.create('Ext.XTemplate',
                '<div>',
                    '<span>{fundName}</span>',
                    '<span>{[this.getPercentage(values.allocation)]}%</span>',
                '</div>',
                {
                    getPercentage: function (allocation) {
                        return Ext.Number.toFixed(allocation / me.totalAllocation, 2);
                    }
                }
            )
            templateStore.load();
            me.callParent(arguments);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following entity: public class Store { public List<Product> Products
Say I have the following model: class Person(models.Model): street_address = models.CharField(max_length=50, blank=True) suburb =
Lets say we have following models. class User(db.Model): username=db.StringProperty() avatar=db.ReferenceProperty() class User(db.Model): username=db.StringProperty() avatar=db.StringProperty()
Let's say we have following this: <p class=first>This is paragraph 1.</p> <p class=second>This is
Let's say we have the following XML document: <root> <options> ... </options> <children> <child
Say I have the following template function: template <class T> void apply(const vector<complex<T> >&
Lets say I have the following code: public class Base { // Some stuff
Say I have following class: Class A { B b; C c; D d;
Let's say we have the following simple model: public class Car { public int
Let's say I have the following entities: Store: component { property name=Id fieldtype=id generator=native;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.