Question

I need to set values ​​in a text field, obtaining a data.Model these values​​, but when I run the function anywhere in the code, sends me this error:

Uncaught TypeError: Can not read property 'get' of undefined

But if I run it from a button works fine.

this is the code:

function SetterValues() {

                var rec = store_usr.getAt(0);
        Ext.getCmp('name_usr').setValue(rec.get("user"));
        Ext.getCmp('nom_usr').setValue(rec.get("name"));
        Ext.getCmp('ape_usr').setValue(rec.get("LastName"));

} 

Help please! because I can not run it from anywhere in my code!

Was it helpful?

Solution

The error message you're receiving indicates that the rec variable is undefined. Are you sure that your store_usr exists, and is loaded? If so, does store_usr.getAt(0) return anything?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top