Get value of DisplayField beforeRender

885 Views Asked by At

I have a displayfield as follows

 {
      fieldLabel: 'Designation', name: 'designation', xtype: 'displayfield',
      listeners: {
            beforerender: 
            {
                   fn: function (v) {
                        // get value here
                   },
                   scope: this
            }
      }
}

I tried to get value of displayfield using

v.getValue(), v.el.getValue(), v.getEl().getValue()

But everytime it shows undefined.

I also tried changing beforerender listener to render. But still the value id undefined.

Can anybody help me out of it.

2

There are 2 best solutions below

2
Robert Watkins On

So, as I understand it - you're relying on the form to populate the displayfield.

Given that's the case, the value is populated after rendering - so it won't be available during the rendering process.

You can prove that by creating a setValue method of your own, and putting a breakpoint in. This will let you see when the value is populated, relative to the rendering process.

Without more details on how you get the JSON object and when it's used to populate the form, I can't help you much more.

0
Binay Das On

Assuming you are loading the value using a store proxy, you can listen to the store's load event rather than the view's render event since the store data is loaded into the view only after the view is rendered completely.