Search code examples
javascriptextjsfrontend

How can I show the first value of store on text field, in ExtJS?


I'm new in ExtJS. I want to show store's first value on textfield. I researched but couldn't find it. How can I do it?


Solution

  • Let's say you have your store in store variable, your field in field and you'd like to set the property of "property" of the first record as the textfield's value:

    field.setValue(store.getAt(0).get('property'));
    

    You have the make sure the store has at least 1 record:

    if (store.getCount()>0)