0

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.

Microsoft DN
  • 9,706
  • 10
  • 51
  • 71
  • How are u setting the Value for this DisplayField ? – JChap Apr 07 '16 at 08:59
  • @JChap: I have the JSON response and the value of 'designation' is binding to displayfield using `name: 'designation'` – Microsoft DN Apr 07 '16 at 09:16
  • Need some more info, Are you using form.loadRecord/form.setValues to bind the json to form or are you using viewModel to bind the data ? – JChap Apr 07 '16 at 09:34

2 Answers2

0

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.

Robert Watkins
  • 2,196
  • 15
  • 17
  • Thanks for the reply. The JSON value I am getting is fetched from database. and it is populated on the form on form load. I understand the value wont be available before render. I just want the actual JSON value which I am getting from database – Microsoft DN Apr 07 '16 at 09:31
  • It won't be available at the time of rendering either, though. The form will render and then populate the values afterwards. – Robert Watkins Apr 07 '16 at 20:48
0

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.

Binay Das
  • 37
  • 5