horcle_buzz
horcle_buzz

Reputation: 2171

ExtJS: How do I bind a label to a ViewModel store with a Single record

Please see the following Fiddle: Bind store from a ViewModel to an xtype label

I am NOT able to get the record from my ViewModel's store to display in the xtype: 'label' item of my form.

This should be easy, but alas my brain is not able to work...

Upvotes: 1

Views: 2369

Answers (2)

Jorge
Jorge

Reputation: 41

In version 7.4:

bind: {
    html: '<b>{testStore.first.test}</b>'
}

Upvotes: 1

scebotari66
scebotari66

Reputation: 3480

There is no way to create a bind descriptor for the first record of a store. You will need to implement a formula for this purpose.

In your view model:

formulas: {
    firstTestStoreRecord: {
        bind: '{testStore}',
        get: function(testStore) {
            return testStore.getAt(0);
        }
    }
}

Then use this in your view:

bind: {
    html: '<b>{firstTestStoreRecord.test}</b>'
}

Here is the working fiddle: https://fiddle.sencha.com/#fiddle/25cf&view/editor

Upvotes: 7

Related Questions